/** * Invoke a app hook. * * @param string $name * @param array $args * * @return AppConfig */ public function hook($name, $args) { $hook = \Novosga\Util\Arrays::value($this->hooks(), $name); if (is_callable($hook)) { if (!is_array($args)) { $args = [$args]; } call_user_func_array($hook, $args); } return $this; }
public function create(Context $context, array $config = array()) { $type = Arrays::value($config, 'type'); $providerConfig = Arrays::value($config, $type, array()); $em = $context->database()->createEntityManager(); switch ($type) { case 'ldap': return new LdapProvider($em, $providerConfig); default: return new DatabaseProvider($em, $providerConfig); } }
public function init(array $config) { if (!empty($config)) { parent::init($config); $this->host = Arrays::value($config, 'host'); $this->baseDn = Arrays::value($config, 'baseDn'); $this->loginAttribute = Arrays::value($config, 'loginAttribute'); $this->username = Arrays::value($config, 'username'); $this->password = Arrays::value($config, 'password'); $this->filter = Arrays::value($config, 'filter'); } }
public function get($name) { if (strpos($name, '.') !== false) { $tokens = explode('.', $name); $value = $this->data; foreach ($tokens as $token) { if ($value === null) { break; } $value = Arrays::value($value, $token, null); } return $value; } return Arrays::value($this->data, $name, null); }
public static function getValue($obj, $prop) { if (is_array($obj)) { return Arrays::value($obj, $prop, null); } if (is_object($obj)) { try { return self::getPropertyValue($obj, $prop); } catch (Exception $e) { try { return self::invokeMethod($obj, 'get' . ucfirst($prop)); } catch (Exception $e) { try { return self::invokeMethod($obj, "get_{$prop}"); } catch (Exception $e) { } } } } throw new Exception("Cannot find value of {$prop} in object " . get_class($obj)); }
/** * Extra route configuration * @return array */ public function routes() { return \Novosga\Util\Arrays::value($this->extra(), 'routes', array()); }
public function getParameter($key) { return Arrays::value($this->parameters, $key); }
/** * @return array */ public function getScripts() { return Arrays::value($this->data, 'scripts', array()); }
/** * Retorna o valor da chave guardada no cookie. * * @param String $key * * @return mixed */ public function get($key) { return Arrays::value($_COOKIE, $key); }