@@ -351,7 +351,7 @@ discard block |
||
| 351 | 351 | */ |
| 352 | 352 | public function completed($name = null) |
| 353 | 353 | { |
| 354 | - if($this->submitted($name) && $this->valid()) { |
|
| 354 | + if ($this->submitted($name) && $this->valid()) { |
|
| 355 | 355 | $this->broadcast('completed'); |
| 356 | 356 | return true; |
| 357 | 357 | } |
@@ -493,7 +493,7 @@ discard block |
||
| 493 | 493 | $errors = []; |
| 494 | 494 | |
| 495 | 495 | foreach ($this->fields as $field) { |
| 496 | - foreach($field->errors() as $error) { |
|
| 496 | + foreach ($field->errors() as $error) { |
|
| 497 | 497 | $errors[] = $error; |
| 498 | 498 | } |
| 499 | 499 | } |
@@ -615,8 +615,8 @@ discard block |
||
| 615 | 615 | { |
| 616 | 616 | $config = $this->templateConfig($template); |
| 617 | 617 | |
| 618 | - if ( isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 619 | - foreach($config['plugins'] as $key => $plugin) { |
|
| 618 | + if (isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 619 | + foreach ($config['plugins'] as $key => $plugin) { |
|
| 620 | 620 | if (is_array($plugin)) { |
| 621 | 621 | $this->addPlugin($key, $plugin); |
| 622 | 622 | } else { |
@@ -636,8 +636,8 @@ discard block |
||
| 636 | 636 | { |
| 637 | 637 | $config = $this->templateConfig($template); |
| 638 | 638 | |
| 639 | - if ( isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 640 | - foreach($config['plugins'] as $plugin) { |
|
| 639 | + if (isset($config['plugins']) && is_array($config['plugins'])) { |
|
| 640 | + foreach ($config['plugins'] as $plugin) { |
|
| 641 | 641 | $this->removePlugin($plugin); |
| 642 | 642 | } |
| 643 | 643 | } |
@@ -674,7 +674,7 @@ discard block |
||
| 674 | 674 | foreach ($field->errors() as $error => $parameters) { |
| 675 | 675 | |
| 676 | 676 | if ($error == 'userDefined') { |
| 677 | - foreach($parameters as $message) { |
|
| 677 | + foreach ($parameters as $message) { |
|
| 678 | 678 | $properties['errors'][] = ['error' => $message]; |
| 679 | 679 | } |
| 680 | 680 | } else { |
@@ -683,7 +683,7 @@ discard block |
||
| 683 | 683 | |
| 684 | 684 | $message = $this->translate($error, $field); |
| 685 | 685 | |
| 686 | - foreach($parameters as $key => $value) { |
|
| 686 | + foreach ($parameters as $key => $value) { |
|
| 687 | 687 | if (is_object($value) && method_exists($value, '__toString')) $value = (string) $value; |
| 688 | 688 | if (is_array($value)) $value = implode(', ', $value); |
| 689 | 689 | $message = str_replace('['.$key.']', $value, $message); |
@@ -949,7 +949,7 @@ discard block |
||
| 949 | 949 | */ |
| 950 | 950 | private function broadcast($event, $params = []) |
| 951 | 951 | { |
| 952 | - foreach($this->plugins as $plugin) { |
|
| 952 | + foreach ($this->plugins as $plugin) { |
|
| 953 | 953 | $plugin->event($this, $event, $params); |
| 954 | 954 | } |
| 955 | 955 | } |
@@ -1090,7 +1090,7 @@ discard block |
||
| 1090 | 1090 | { |
| 1091 | 1091 | if ( ! method_exists($this, $method)) |
| 1092 | 1092 | { |
| 1093 | - if ( $this->typeExists($method)) { |
|
| 1093 | + if ($this->typeExists($method)) { |
|
| 1094 | 1094 | return $this->addField($method, array_shift($parameters)); |
| 1095 | 1095 | } |
| 1096 | 1096 | } |
@@ -12,14 +12,14 @@ discard block |
||
| 12 | 12 | * |
| 13 | 13 | * @var string |
| 14 | 14 | */ |
| 15 | - protected $path; |
|
| 15 | + protected $path; |
|
| 16 | 16 | |
| 17 | - /** |
|
| 17 | + /** |
|
| 18 | 18 | * Create a new plugin instance. |
| 19 | 19 | * |
| 20 | 20 | */ |
| 21 | - public function __construct($config = null) |
|
| 22 | - { |
|
| 21 | + public function __construct($config = null) |
|
| 22 | + { |
|
| 23 | 23 | if (is_array($config) && count($config)) { |
| 24 | 24 | foreach ($config as $key => $value) { |
| 25 | 25 | $method = 'set'.Str::studly($key); |
@@ -29,42 +29,42 @@ discard block |
||
| 29 | 29 | } |
| 30 | 30 | } |
| 31 | 31 | |
| 32 | - $this->setPath(); |
|
| 33 | - } |
|
| 32 | + $this->setPath(); |
|
| 33 | + } |
|
| 34 | 34 | |
| 35 | - /** |
|
| 35 | + /** |
|
| 36 | 36 | * Set the plugin autoload path. |
| 37 | 37 | * |
| 38 | 38 | * @return void |
| 39 | 39 | */ |
| 40 | - public function setPath() |
|
| 41 | - { |
|
| 40 | + public function setPath() |
|
| 41 | + { |
|
| 42 | 42 | $this->path = Reflect::getDirectory($this); |
| 43 | - } |
|
| 43 | + } |
|
| 44 | 44 | |
| 45 | - /** |
|
| 45 | + /** |
|
| 46 | 46 | * Get autoload path. |
| 47 | 47 | * |
| 48 | 48 | * @return string |
| 49 | 49 | */ |
| 50 | - public function path($append = null) |
|
| 51 | - { |
|
| 52 | - return is_null($append) ? $this->path |
|
| 53 | - : $this->path.'/'.ltrim(rtrim($append, '/'), '/').'/'; |
|
| 54 | - } |
|
| 50 | + public function path($append = null) |
|
| 51 | + { |
|
| 52 | + return is_null($append) ? $this->path |
|
| 53 | + : $this->path.'/'.ltrim(rtrim($append, '/'), '/').'/'; |
|
| 54 | + } |
|
| 55 | 55 | |
| 56 | - /** |
|
| 56 | + /** |
|
| 57 | 57 | * Get paths to templates. |
| 58 | 58 | * |
| 59 | 59 | * @return string |
| 60 | 60 | */ |
| 61 | - public function templatePaths() |
|
| 62 | - { |
|
| 63 | - $path = $this->path('templates'); |
|
| 64 | - return [$path]; |
|
| 65 | - } |
|
| 61 | + public function templatePaths() |
|
| 62 | + { |
|
| 63 | + $path = $this->path('templates'); |
|
| 64 | + return [$path]; |
|
| 65 | + } |
|
| 66 | 66 | |
| 67 | - /** |
|
| 67 | + /** |
|
| 68 | 68 | * Trigger an event callback. |
| 69 | 69 | * - onLoad |
| 70 | 70 | * - onDefine |
@@ -76,19 +76,19 @@ discard block |
||
| 76 | 76 | * - onValid |
| 77 | 77 | * - onInvalid |
| 78 | 78 | * |
| 79 | - * @param \Helmut\Forms\Form $form |
|
| 80 | - * @param string $name |
|
| 81 | - * @param array $params |
|
| 79 | + * @param \Helmut\Forms\Form $form |
|
| 80 | + * @param string $name |
|
| 81 | + * @param array $params |
|
| 82 | 82 | * @return mixed |
| 83 | 83 | */ |
| 84 | - public function event($form, $name, $params = []) |
|
| 85 | - { |
|
| 86 | - $name = Str::studly($name); |
|
| 84 | + public function event($form, $name, $params = []) |
|
| 85 | + { |
|
| 86 | + $name = Str::studly($name); |
|
| 87 | 87 | |
| 88 | - if (method_exists($this, 'on'.$name)) { |
|
| 89 | - return call_user_func_array(array($this, 'on'.$name), [$form, $params]); |
|
| 90 | - } |
|
| 88 | + if (method_exists($this, 'on'.$name)) { |
|
| 89 | + return call_user_func_array(array($this, 'on'.$name), [$form, $params]); |
|
| 90 | + } |
|
| 91 | 91 | |
| 92 | - } |
|
| 92 | + } |
|
| 93 | 93 | |
| 94 | 94 | } |