/** * Initializes the context with the connection to the storage backend. * * @param \TechDivision\Configuration\Interfaces\NodeInterface $systemConfiguration The system configuration */ public function __construct(NodeInterface $systemConfiguration) { // initialize the storage $initialContextNode = $systemConfiguration->getInitialContext(); $storageNode = $initialContextNode->getStorage(); $reflectionClass = $this->newReflectionClass($storageNode->getType()); // create the storage instance $storage = $reflectionClass->newInstance(); // append the storage servers registered in system configuration foreach ($storageNode->getStorageServers() as $storageServer) { $storage->addServer($storageServer->getAddress(), $storageServer->getPort(), $storageServer->getWeight()); } // add the storage to the initial context $this->setStorage($storage); // initialize the class loader instance $classLoaderNode = $initialContextNode->getClassLoader(); $reflectionClass = $this->newReflectionClass($classLoaderNode->getType()); $this->setClassLoader($reflectionClass->newInstanceArgs(array($this))); // attach the system configuration to the initial context $this->setSystemConfiguration($systemConfiguration); }
/** * Prepares the rewrite maps array based on a node implementing NodeInterface * * @param \TechDivision\Configuration\Interfaces\NodeInterface $node The node instance * * @return array */ public function prepareRewriteMaps(NodeInterface $node) { $rewriteMaps = array(); if (is_array($node->getRewriteMaps())) { foreach ($node->getRewriteMaps() as $rewriteMap) { $rewriteMapType = $rewriteMap->getType(); // set all rewrite maps information's $rewriteMaps[$rewriteMapType] = $rewriteMap->getParamsAsArray(); } } return $rewriteMaps; }
/** * Adds the .dodeploy flag file in the deploy folder, therefore the * app will be deployed with the next restart. * * @param \TechDivision\Configuration\Interfaces\NodeInterface $appNode The application node object * * @return void */ public function deploy(NodeInterface $appNode) { // prepare file name $fileName = $appNode->getName() . PharExtractor::EXTENSION_SUFFIX; // load the file info $archive = new \SplFileInfo($this->getDeployDir() . DIRECTORY_SEPARATOR . $fileName); // flag the archiv => deploy it with the next restart $extractor = new PharExtractor($this->getInitialContext()); $extractor->flagArchive($archive, ExtractorInterface::FLAG_DODEPLOY); }