Beispiel #1
0
 /**
  * Modify class source
  *
  * @param \Includes\Decorator\DataStructure\Graph\Classes $node Current node
  *
  * @return void
  */
 protected function writeCallToSourceFile(\Includes\Decorator\DataStructure\Graph\Classes $node)
 {
     $path = \Includes\Decorator\ADecorator::getCacheClassesDir() . $node->getPath();
     $content = \Includes\Utils\FileManager::read($path);
     $content .= PHP_EOL . '// Call static constructor' . PHP_EOL;
     $content .= '\\' . $node->getClass() . '::' . static::STATIC_CONSTRUCTOR_METHOD . '();';
     \Includes\Utils\FileManager::write($path, $content);
 }
Beispiel #2
0
 /**
  * Get allowed commands
  *
  * @return array
  */
 public function getAllowedCommands()
 {
     $dsQuoted = preg_quote(LC_DS, '/');
     $path = \Includes\Decorator\ADecorator::getCacheClassesDir() . 'XLite' . LC_DS . 'Controller' . LC_DS . 'Console' . LC_DS . '*.php';
     $commands = array();
     $list = glob($path);
     if ($list) {
         foreach ($list as $f) {
             if (!preg_match('/Abstract.php$/Ss', $f) && !preg_match('/' . $dsQuoted . 'A[A-Z]/Ss', $f)) {
                 $commands[] = strtolower(substr(basename($f), 0, -4));
             }
         }
     }
     return $commands;
 }
Beispiel #3
0
 /**
  * Write PHP class to the files
  *
  * @param \Includes\Decorator\DataStructure\Graph\Classes $node   Current class node
  * @param \Includes\Decorator\DataStructure\Graph\Classes $parent Parent class node
  *
  * @return void
  */
 public static function writeClassFile(\Includes\Decorator\DataStructure\Graph\Classes $node, \Includes\Decorator\DataStructure\Graph\Classes $parent = null)
 {
     \Includes\Utils\FileManager::write(\Includes\Decorator\ADecorator::getCacheClassesDir() . $node->getPath(), $node->getSource($parent));
 }
Beispiel #4
0
 /**
  * Correct (if needed) class doc block comment. Works for one element from the queue
  *
  * @param \Includes\Decorator\DataStructure\Graph\Classes $node Current node
  *
  * @return void
  */
 protected function correctTagsOnElement(\Includes\Decorator\DataStructure\Graph\Classes $node)
 {
     $path = \Includes\Decorator\ADecorator::getCacheClassesDir() . $node->getPath();
     \Includes\Utils\FileManager::write($path, \Includes\Decorator\Utils\Tokenizer::getSourceCode($path, null, null, null, call_user_func_array(array($node, 'addLinesToDocBlock'), $this->getTagsToAdd($node)), $node->isDecorator() ? 'abstract' : null));
 }
Beispiel #5
0
 /**
  * Check if class exists
  *
  * @param string $name Name of class to check
  *
  * @return boolean
  */
 public static function isClassExists($name)
 {
     return class_exists($name, false) || file_exists(\Includes\Decorator\ADecorator::getCacheClassesDir() . str_replace('\\', LC_DS, $name) . '.php');
 }
Beispiel #6
0
 /**
  * Get compress file path 
  * 
  * @return string
  */
 protected function getPath()
 {
     return \Includes\Decorator\ADecorator::getCacheClassesDir() . 'core.php';
 }
Beispiel #7
0
 /**
  * Generate models
  *
  * @return void
  */
 public static function generateModels()
 {
     static::getEntityGenerator()->generate(static::getAllMetadata(), \Includes\Decorator\ADecorator::getCacheClassesDir());
 }
Beispiel #8
0
 /**
  * Put prepared code into the files
  *
  * @return void
  */
 protected function writeData()
 {
     foreach ($this->replacements as $file => $code) {
         \Includes\Utils\FileManager::write($file = \Includes\Decorator\ADecorator::getCacheClassesDir() . $file, \Includes\Decorator\Utils\Tokenizer::addCodeToClassBody($file, $code));
     }
 }
Beispiel #9
0
 /**
  * Correct (if needed) class doc block comment. Works for one element from the queue
  *
  * @param \Includes\Decorator\DataStructure\Graph\Classes $node Current node
  *
  * @return void
  */
 protected function correctTagsOnElement(\Includes\Decorator\DataStructure\Graph\Classes $node)
 {
     \Includes\Utils\FileManager::replace(\Includes\Decorator\ADecorator::getCacheClassesDir() . $node->getPath(), '@$1 ' . $this->getRepositoryCustomClassParameter($node), \Includes\Decorator\Utils\Operator::getTagPattern(array('Entity', 'MappedSuperClass')));
 }
Beispiel #10
0
 /**
  * Name of the origin class file
  *
  * @param string $class Class name OPTIONAL
  * @param string $dir   Dir to file OPTIONAL
  *
  * @return string
  */
 public function getFile($class = null, $dir = null)
 {
     $dir = $dir ?: \Includes\Decorator\ADecorator::getCacheClassesDir();
     return $dir . $this->getPath($class);
 }
Beispiel #11
0
 /**
  * Initialize classes directory
  * 
  * @return void
  */
 protected static function initializeClassesDir()
 {
     static::$lcAutoloadDir = \Includes\Decorator\ADecorator::getCacheClassesDir();
 }
Beispiel #12
0
 /**
  * Connect and set-up Doctrine
  *
  * @return void
  */
 public function connect()
 {
     $this->configuration = new \Doctrine\ORM\Configuration();
     // Setup cache
     $this->setDoctrineCache();
     // Set metadata driver
     $chain = new \Doctrine\Common\Persistence\Mapping\Driver\MappingDriverChain();
     $chain->addDriver($this->createAnnotationDriver(\Includes\Decorator\ADecorator::getCacheModelsDir()), 'XLite\\Model');
     $iterator = new \RecursiveDirectoryIterator(\Includes\Decorator\ADecorator::getCacheClassesDir() . 'XLite' . LC_DS . 'Module', \FilesystemIterator::SKIP_DOTS);
     foreach ($iterator as $dir) {
         if (\Includes\Utils\FileManager::isDir($dir->getPathName())) {
             $iterator2 = new \RecursiveDirectoryIterator($dir->getPathName(), \FilesystemIterator::SKIP_DOTS);
             foreach ($iterator2 as $dir2) {
                 if (\Includes\Utils\FileManager::isDir($dir2->getPathName()) && \Includes\Utils\FileManager::isDir($dir2->getPathName() . LC_DS . 'Model')) {
                     $chain->addDriver($this->createAnnotationDriver($dir2->getPathName() . LC_DS . 'Model'), 'XLite\\Module\\' . $dir->getBaseName() . '\\' . $dir2->getBaseName() . '\\Model');
                 }
             }
         }
     }
     $this->configuration->setMetadataDriverImpl($chain);
     // Set proxy settings
     $this->configuration->setProxyDir(rtrim(\Includes\Decorator\ADecorator::getCacheModelProxiesDir(), LC_DS));
     $this->configuration->setProxyNamespace(LC_MODEL_PROXY_NS);
     $this->configuration->setAutoGenerateProxyClasses(false);
     // Register custom functions
     $this->configuration->addCustomStringFunction('if', '\\XLite\\Core\\Doctrine\\IfFunction');
     $this->configuration->addCustomStringFunction('IFNULL', '\\XLite\\Core\\Doctrine\\IfnullFunction');
     $this->configuration->addCustomStringFunction('relevance', '\\XLite\\Core\\Doctrine\\RelevanceFunction');
     $this->configuration->addCustomNumericFunction('intval', '\\XLite\\Core\\Doctrine\\IntvalFunction');
     $this->configuration->addCustomStringFunction('findInSet', '\\XLite\\Core\\Doctrine\\FindInSetFunction');
     $this->configuration->addCustomStringFunction('castChar', '\\XLite\\Core\\Doctrine\\CastCharFunction');
     $this->configuration->addCustomStringFunction('collate', '\\XLite\\Core\\Doctrine\\CollateFunction');
     $this->tablePrefix = trim(\XLite::getInstance()->getOptions(array('database_details', 'table_prefix')));
     // Initialize DB connection and entity manager
     $this->startEntityManager();
 }