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