Extract child instructions

This commit is contained in:
Nathan van der Werf 2018-08-15 19:25:42 +02:00
parent fbca3bea92
commit 8b6f11e6ac
16 changed files with 68 additions and 89 deletions

View File

@ -1445,9 +1445,8 @@ class RelationController extends ControllerBehavior
if ($this->eventTarget == 'button-link') {
return 'backend::lang.relation.link_a_new';
}
else {
return 'backend::lang.relation.add_a_new';
}
return 'backend::lang.relation.add_a_new';
case 'form':
if ($this->readOnly) {
return 'backend::lang.relation.preview_name';
@ -1508,9 +1507,8 @@ class RelationController extends ControllerBehavior
if ($this->eventTarget == 'button-add') {
return 'list';
}
else {
return 'form';
}
return 'form';
}
}
@ -1600,9 +1598,8 @@ class RelationController extends ControllerBehavior
if ($throwException) {
throw new ApplicationException('Missing configuration for '.$mode.'.'.$type.' in RelationController definition '.$this->field);
}
else {
return false;
}
return false;
}
return $this->makeConfig($config);

View File

@ -234,9 +234,8 @@ class FormField
return [];
}
else {
$this->options = $value;
}
$this->options = $value;
return $this;
}
@ -567,9 +566,8 @@ class FormField
if ($arrayName) {
return $arrayName.'['.implode('][', HtmlHelper::nameToArray($this->fieldName)).']';
}
else {
return $this->fieldName;
}
return $this->fieldName;
}
/**

View File

@ -80,11 +80,10 @@ abstract class Skin
? $this->publicSkinPath . $path
: $this->skinPath . $path;
}
else {
return $isPublic
? $this->defaultPublicSkinPath . $path
: $this->defaultSkinPath . $path;
}
return $isPublic
? $this->defaultPublicSkinPath . $path
: $this->defaultSkinPath . $path;
}
/**

View File

@ -54,9 +54,8 @@ class Auth extends Controller
if (post('postback')) {
return $this->signin_onSubmit();
}
else {
$this->bodyClass .= ' preload';
}
$this->bodyClass .= ' preload';
}
catch (Exception $ex) {
Flash::error($ex->getMessage());

View File

@ -96,12 +96,11 @@ class User extends UserBase
if ($this->avatar) {
return $this->avatar->getThumb($size, $size, $options);
}
else {
return '//www.gravatar.com/avatar/' .
md5(strtolower(trim($this->email))) .
'?s='. $size .
'&d='. urlencode($default);
}
return '//www.gravatar.com/avatar/' .
md5(strtolower(trim($this->email))) .
'?s='. $size .
'&d='. urlencode($default);
}
/**

View File

@ -1163,9 +1163,9 @@ class Form extends WidgetBase
$key = array_shift($parts);
if (isset($array[$key])) {
return $array[$key];
} else {
return $default;
}
return $default;
}
foreach ($parts as $segment) {

View File

@ -1514,9 +1514,8 @@ class Lists extends WidgetBase
if ($column === null) {
return (count($this->getSortableColumns()) > 0);
}
else {
return array_key_exists($column, $this->getSortableColumns());
}
return array_key_exists($column, $this->getSortableColumns());
}
/**

View File

@ -1303,31 +1303,29 @@ class MediaManager extends WidgetBase
* If the target dimensions are provided, resize the original image and
* return its URL and dimensions.
*/
else {
$originalFilePath = $fullSessionDirectoryPath.'/'.$originalThumbFileName;
if (!File::isFile($originalFilePath)) {
throw new SystemException('The original image is not found in the cropping session directory.');
}
$resizedThumbFileName = 'resized-'.$params['width'].'-'.$params['height'].'.'.$extension;
$tempFilePath = $fullSessionDirectoryPath.'/'.$resizedThumbFileName;
Resizer::open($originalFilePath)
->resize($params['width'], $params['height'], [
'mode' => 'exact'
])
->save($tempFilePath)
;
$url = $this->getThumbnailImageUrl($sessionDirectoryPath.'/'.$resizedThumbFileName);
$dimensions = getimagesize($tempFilePath);
return [
'url' => $url,
'dimensions' => $dimensions
];
$originalFilePath = $fullSessionDirectoryPath.'/'.$originalThumbFileName;
if (!File::isFile($originalFilePath)) {
throw new SystemException('The original image is not found in the cropping session directory.');
}
$resizedThumbFileName = 'resized-'.$params['width'].'-'.$params['height'].'.'.$extension;
$tempFilePath = $fullSessionDirectoryPath.'/'.$resizedThumbFileName;
Resizer::open($originalFilePath)
->resize($params['width'], $params['height'], [
'mode' => 'exact'
])
->save($tempFilePath)
;
$url = $this->getThumbnailImageUrl($sessionDirectoryPath.'/'.$resizedThumbFileName);
$dimensions = getimagesize($tempFilePath);
return [
'url' => $url,
'dimensions' => $dimensions
];
}
catch (Exception $ex) {
if ($sessionDirectoryCreated) {

View File

@ -98,9 +98,9 @@ class Search extends WidgetBase
if ($this->partial) {
return $this->controller->makePartial($this->partial);
} else {
return $this->makePartial('search');
}
return $this->makePartial('search');
}
/**

View File

@ -820,9 +820,8 @@ class Controller
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found_name', ['name'=>$partialName]));
}
else {
return false;
}
return false;
}
}
/*
@ -857,9 +856,8 @@ class Controller
if ($throwException) {
throw new CmsException(Lang::get('cms::lang.partial.not_found_name', ['name'=>$name]));
}
else {
return false;
}
return false;
}
/*

View File

@ -487,9 +487,8 @@ class CombineAssets
if ($actionExists) {
return Url::action($combineAction, [$outputFilename], false);
}
else {
return '/combine/'.$outputFilename;
}
return '/combine/'.$outputFilename;
}
/**

View File

@ -255,9 +255,8 @@ class PluginBase extends ServiceProviderBase
if ($exceptionMessage) {
throw new SystemException($exceptionMessage);
}
else {
$this->loadedYamlConfiguration = [];
}
$this->loadedYamlConfiguration = [];
}
else {
$this->loadedYamlConfiguration = Yaml::parse(file_get_contents($yamlFilePath));

View File

@ -63,9 +63,8 @@ class OctoberUpdate extends Command
$this->output->writeln('<info>No new updates found</info>');
return;
}
else {
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
}
$this->output->writeln(sprintf('<info>Found %s new %s!</info>', $updates, Str::plural('update', $updates)));
$coreHash = $disableCore ? null : array_get($updateList, 'core.hash');
$coreBuild = array_get($updateList, 'core.build');

View File

@ -54,9 +54,8 @@ class File extends FileBase
if ($this->isPublic()) {
return $uploadsFolder . '/public/';
}
else {
return $uploadsFolder . '/protected/';
}
return $uploadsFolder . '/protected/';
}
/**

View File

@ -48,9 +48,8 @@ trait EventEmitter
if ($halt) {
return $response;
}
else {
$result = array_merge($result, $response);
}
$result = array_merge($result, $response);
}
/*
@ -60,9 +59,8 @@ trait EventEmitter
if ($halt) {
return $response;
}
else {
$result = array_merge($result, $response);
}
$result = array_merge($result, $response);
}
return $result;

View File

@ -91,9 +91,8 @@ trait ViewMaker
if ($throwException) {
throw new SystemException(Lang::get('backend::lang.partial.not_found_name', ['name' => $partialPath]));
}
else {
return false;
}
return false;
}
return $this->makeFileContents($partialPath, $params);
@ -151,9 +150,8 @@ trait ViewMaker
if ($throwException) {
throw new SystemException(Lang::get('cms::lang.layout.not_found_name', ['name' => $layoutPath]));
}
else {
return false;
}
return false;
}
return $this->makeFileContents($layoutPath, $params);