Esempio n. 1
0
 /**
  * Define argument type
  *
  * @param mixed $argument
  * @return int
  * @throws \InvalidArgumentException
  */
 protected function getArgumentType($argument) : int
 {
     // This is a dependency which invokes resolving function
     if (is_string($argument)) {
         if ($this->parentContainer !== null && $this->parentContainer->has($argument)) {
             return 1;
         } elseif (array_key_exists($argument, $this->classesMetadata)) {
             return 1;
         } elseif (array_key_exists($argument, $this->classAliases)) {
             return 2;
         } elseif (class_exists($argument)) {
             // If this argument is existing class
             throw new \InvalidArgumentException($argument . ' class metadata is not defined');
         } elseif (interface_exists($argument)) {
             // If this argument is existing interface
             throw new \InvalidArgumentException($argument . ' - interface dependency not resolvable');
         } else {
             // String variable
             return 3;
         }
     } elseif (is_array($argument)) {
         // Dependency value is array
         return 4;
     }
     return 0;
 }
Esempio n. 2
0
 /**
  * Retrieve module instance by identifier.
  *
  * @param string|null $module Module identifier
  *
  * @return null|Module Found or active module
  */
 public function module($module = null)
 {
     $return = null;
     // Ничего не передано - вернем текущуй модуль системы
     if (!isset($module) && isset($this->active)) {
         $return =& $this->active;
     } elseif (is_object($module)) {
         $return =& $module;
     } elseif (is_string($module)) {
         $return = $this->container->get($module);
     }
     //        // Ничего не получилось вернем ошибку
     if ($return === null) {
         e('Не возможно получить модуль(##) системы', E_SAMSON_CORE_ERROR, array($module));
     }
     return $return;
 }