Example #1
0
 public static function initClassesList()
 {
     if (static::$classes !== null) {
         return true;
     }
     $classes = array('\\Bitrix\\Sale\\Delivery\\ExtraServices\\Enum' => 'lib/delivery/extra_services/enum.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store' => 'lib/delivery/extra_services/store.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\String' => 'lib/delivery/extra_services/string.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Checkbox' => 'lib/delivery/extra_services/checkbox.php');
     \Bitrix\Main\Loader::registerAutoLoadClasses('sale', $classes);
     unset($classes['\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store']);
     static::$classes = array_keys($classes);
     foreach (GetModuleEvents("sale", "onSaleDeliveryExtraServicesClassesCustom", true) as $arHandler) {
         $classes = ExecuteModuleEventEx($arHandler);
         if (!is_array($classes)) {
             throw new SystemException('Handler of onSaleDeliveryExtraServicesClassesCustom must return Bitrix\\Sale\\Delivery\\ExtraServices\\Base[]');
         }
         foreach ($classes as $class) {
             if (!class_exists($class)) {
                 throw new SystemException('onSaleDeliveryExtraServicesClassesCustom class doesn\'t exist: "' . $class . '"');
             }
             if (in_array($class, static::$classes)) {
                 throw new SystemException('onSaleDeliveryExtraServicesClassesCustom class with such name alredy exists: "' . $class . '"');
             }
             static::$classes[] = $class;
         }
     }
     return true;
 }
Example #2
0
 public static function initClassesList()
 {
     if (static::$classes !== null) {
         return true;
     }
     $classes = array('\\Bitrix\\Sale\\Delivery\\ExtraServices\\Enum' => 'lib/delivery/extra_services/enum.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store' => 'lib/delivery/extra_services/store.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\String' => 'lib/delivery/extra_services/string.php', '\\Bitrix\\Sale\\Delivery\\ExtraServices\\Checkbox' => 'lib/delivery/extra_services/checkbox.php');
     \Bitrix\Main\Loader::registerAutoLoadClasses('sale', $classes);
     unset($classes['\\Bitrix\\Sale\\Delivery\\ExtraServices\\Store']);
     static::$classes = array_keys($classes);
     $event = new Event('sale', 'onSaleDeliveryExtraServicesClassNamesBuildList');
     $event->send();
     $resultList = $event->getResults();
     if (is_array($resultList) && !empty($resultList)) {
         $customClasses = array();
         foreach ($resultList as $eventResult) {
             /** @var  EventResult $eventResult*/
             if ($eventResult->getType() != EventResult::SUCCESS) {
                 throw new SystemException("Can't add custom tracking class successfully");
             }
             $params = $eventResult->getParameters();
             if (!empty($params) && is_array($params)) {
                 $customClasses = array_merge($customClasses, $params);
             }
         }
         if (!empty($customClasses)) {
             \Bitrix\Main\Loader::registerAutoLoadClasses(null, $customClasses);
             $classes = array_merge($customClasses, $classes);
         }
     }
     static::$classes = array_merge(array_keys($classes), static::$classes);
     return static::$classes;
 }
Example #3
0
 /**
  * @param string $file file path
  * @return \ReflectionClass
  */
 public static function getClass($file)
 {
     $file = (string) $file;
     if (!static::$classes) {
         static::$classes = new ArrayCollection();
     }
     if (!static::$classes->get($file)) {
         $name = ReflectionManager::getClassName($file);
         static::$classes->set($file, new \ReflectionClass($name));
     }
     return static::$classes->get($file);
 }
Example #4
0
 private function scanImplementations()
 {
     static::$container = Drupal::getContainer();
     static::$classes = $this->AutoloaderInit();
     foreach (static::getFiles('/^.+\\.(inc|php)$/i') as $submodule) {
         $code = file_get_contents($submodule);
         preg_match('/\\s+namespace\\s+([^\\s]+)\\s*;/i', $code, $matches);
         $namespace = $matches ? $matches[1] : '';
         preg_match('/\\s+(class|trait|interface)\\s+([^\\s]+)/i', $code, $matches);
         $class = $matches ? $matches[2] : '';
         if ($class && $namespace) {
             $class = $namespace . '\\' . $class;
         }
         if ($class && class_exists($class) && (new ReflectionClass($class))->isInstantiable()) {
             $functions = array_map(function ($method) {
                 return $method->name;
             }, (new ReflectionClass($class))->getMethods(ReflectionMethod::IS_PUBLIC));
         } elseif (!$class) {
             preg_match_all('/\\s+function\\s+([^\\s]+)\\s*\\(/i', $code, $matches);
             $functions = $matches[1];
         } else {
             continue;
         }
         require_once $submodule;
         foreach ($functions as $function) {
             if (!$class && $namespace) {
                 $function = $namespace . '\\' . $function;
             }
             if (!$class && function_exists($function)) {
                 $function_info = new ReflectionFunction($function);
             } elseif ($class && method_exists($class, $function)) {
                 $function_info = new ReflectionMethod($class, $function);
             } else {
                 continue;
             }
             $doc_block = new DocBlock($function_info->getDocComment() ?: '');
             $function = $class ? "{$class}::{$function}" : $function;
             if ($doc_block->event) {
                 $this->events[] = ['name' => $doc_block->event, 'listener' => $class ? $function : $this->generateCallbackName($function), 'priority' => (int) $doc_block->priority];
                 if (!$class) {
                     $doc_block->implement = 'callback';
                 }
             }
             if ($doc_block->implement) {
                 $this->implementations[$doc_block->implement][] = ['uri' => $class ? NULL : $submodule, 'class' => $class, 'function' => $function, 'doc_block' => $doc_block, 'arguments' => $this->convertParametersToString($function_info->getParameters())];
             }
         }
     }
 }
Example #5
0
 public static function parse($selector)
 {
     $selector = trim($selector);
     $selectors = explode(',', $selector);
     foreach ($selectors as $k => $selector) {
         $selector = '//' . trim($selector);
         $selector = self::axes($selector);
         $selector = self::attributes($selector);
         $selector = self::pclasses($selector);
         $selector = self::ids($selector);
         static::$classes = 0;
         $selector = self::classes($selector);
         $selector = str_replace(' ', '//', $selector);
         $selectors[$k] = $selector;
     }
     $selector = implode(' | ', $selectors);
     return $selector;
 }
Example #6
0
 public static function reload($reload = false)
 {
     $key = 'lbry-classes-4';
     if (ini_get('apc.enabled') && !$reload) {
         $classes = apc_fetch($key, $success);
         if ($success) {
             static::$classes = $classes;
             return;
         }
     }
     static::$classes = [];
     $dir = new RecursiveDirectoryIterator($_SERVER['ROOT_DIR'], RecursiveDirectoryIterator::SKIP_DOTS);
     $ite = new RecursiveIteratorIterator($dir);
     $pathIterator = new RegexIterator($ite, '/.*\\.class\\.php/', RegexIterator::GET_MATCH);
     foreach ($pathIterator as $paths) {
         foreach ($paths as $path) {
             static::$classes += static::parseFile($path);
         }
     }
     if (ini_get('apc.enabled')) {
         apc_store($key, static::$classes);
     }
 }
Example #7
0
 /**
  * Add one or more class to the autoloader
  *
  * @param string 	$name
  * @param path 		$path
  * @return void
  */
 public static function bind($name, $path = null)
 {
     if (is_array($name)) {
         static::$classes = array_merge(static::$classes, $name);
         return;
     }
     static::$classes[$name] = $path;
 }
Example #8
0
 public static function init()
 {
     static::$classes = array('DebugBar' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'DebugBar.php', 'DebugPanel' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'DebugPanel.php', 'ApcPanel' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'panels' . DIRECTORY_SEPARATOR . 'ApcPanel.php', 'HttpRequestPanel' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'panels' . DIRECTORY_SEPARATOR . 'HttpRequestPanel.php', 'MemcachedPanel' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'panels' . DIRECTORY_SEPARATOR . 'MemcachedPanel.php', 'PhpInfoPanel' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'panels' . DIRECTORY_SEPARATOR . 'PhpInfoPanel.php', 'ResourcesPanel' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'panels' . DIRECTORY_SEPARATOR . 'ResourcesPanel.php', 'SqlPanel' => DEBUGBAR_PATH . 'lib' . DIRECTORY_SEPARATOR . 'panels' . DIRECTORY_SEPARATOR . 'SqlPanel.php');
 }
 public function resetEmpty()
 {
     static::$cache = null;
     static::$classes = [];
 }
Example #10
0
 /**
  * unload
  *
  * @return $this
  */
 public function unload()
 {
     static::$classes = array_diff(static::$classes, [$this->class]);
     $this->loaded = false;
     return $this;
 }
 public static function addClasses($classes)
 {
     static::$classes = $classes;
 }