コード例 #1
0
 /**
  * @param string $key
  * @param mixed  $value
  *
  * @return mixed
  */
 public function getOptions($key, $value)
 {
     if (isset($this->callbackOptions)) {
         return Callback::invoke($this->callbackOptions, [$value], ['{model}' => $this->model]);
     }
     if ($this->hasGetOptionsMethod($key)) {
         return $this->callGetOptionsMethod($key, $value);
     }
     return [];
 }
コード例 #2
0
 /**
  * @param string $uri
  *
  * @return string
  */
 public function executeRoute($uri)
 {
     if (empty($uri)) {
         return;
     }
     if (is_null($method = $this->getRouter()->findRouteByUri($uri))) {
         $this->page = FrontendPage::findByUri($uri, $this->page);
         return;
     }
     if (strpos($method, '::') !== false) {
         Callback::invoke($method, [$this]);
     } else {
         $this->{$method}();
     }
     return $method;
 }
コード例 #3
0
 /**
  * @return mixed
  */
 protected function getCallbackValue()
 {
     return Callback::invoke($this->callbackValue, $this->callbackParameters);
 }
コード例 #4
0
ファイル: Filter.php プロジェクト: KodiComponents/module-core
 /**
  * @param string $field
  * @param mixed  $value
  * @param array  $rules
  *
  * @return mixed
  */
 public function filterFieldValue($field, $value, array $rules = null)
 {
     if (empty($rules)) {
         $rules = array_get($this->rules, $field . '.rules', []);
     }
     // Bind the field name and model so they can be used in the filter method
     $_bound = [':field' => $field, ':filter' => $this];
     foreach ($rules as $filter) {
         // Value needs to be bound inside the loop so we are always using the
         // version that was modified by the filters that already ran
         $_bound[':value'] = $value;
         $params = [':value'];
         foreach ($params as $key => $param) {
             if (is_string($param) and array_key_exists($param, $_bound)) {
                 // Replace with bound value
                 $params[$key] = $_bound[$param];
             }
         }
         $value = Callback::invoke($filter, $params);
     }
     return $value;
 }