Esempio n. 1
0
 /**
  * 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);
     }
 }
Esempio n. 3
0
 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');
     }
 }
Esempio n. 4
0
 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);
 }
Esempio n. 5
0
 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));
 }
Esempio n. 6
0
 /**
  * Extra route configuration
  * @return array
  */
 public function routes()
 {
     return \Novosga\Util\Arrays::value($this->extra(), 'routes', array());
 }
Esempio n. 7
0
 public function getParameter($key)
 {
     return Arrays::value($this->parameters, $key);
 }
Esempio n. 8
0
 /**
  * @return array
  */
 public function getScripts()
 {
     return Arrays::value($this->data, 'scripts', array());
 }
Esempio n. 9
0
 /**
  * Retorna o valor da chave guardada no cookie.
  *
  * @param String $key
  *
  * @return mixed
  */
 public function get($key)
 {
     return Arrays::value($_COOKIE, $key);
 }