public function prepare(ContainerInterface $container, ContextNode $contextNode)
    {

        // set the application configuration
        $this->contextNode = $contextNode;

        // load the unique application name + the naming directory
        $uniqueName = $this->getUniqueName();
        $namingDirectory = $this->getNamingDirectory();

        // create subdirectories for the application and the logger
        $namingDirectory->createSubdirectory(sprintf('php:global/%s', $uniqueName));
        $namingDirectory->createSubdirectory(sprintf('php:global/log/%s', $uniqueName));

        // create the applications 'env' + 'env/persistence' directory the beans + persistence units will be bound to
        $namingDirectory->createSubdirectory(sprintf('php:env/%s', $uniqueName));
        $namingDirectory->createSubdirectory(sprintf('php:global/%s/env', $uniqueName));
        $namingDirectory->createSubdirectory(sprintf('php:global/%s/env/persistence', $uniqueName));

        // bind the directory containing the applications
        $namingDirectory->bind(sprintf('php:env/%s/appBase', $uniqueName), $container->getAppBase());

        // prepare the application specific directories
        $webappPath = sprintf('%s/%s', $this->getAppBase(), $this->getName());
        $tmpDirectory = sprintf('%s/%s', $container->getTmpDir(), $this->getName());
        $dataDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::DATA), '/'));
        $cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::CACHE), '/'));
        $sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::SESSION), '/'));

        // prepare the application specific environment variables
        $namingDirectory->bind(sprintf('php:env/%s/webappPath', $uniqueName), $webappPath);
        $namingDirectory->bind(sprintf('php:env/%s/tmpDirectory', $uniqueName), $tmpDirectory);
        $namingDirectory->bind(sprintf('php:env/%s/dataDirectory', $uniqueName), $dataDirectory);
        $namingDirectory->bind(sprintf('php:env/%s/cacheDirectory', $uniqueName), $cacheDirectory);
        $namingDirectory->bind(sprintf('php:env/%s/sessionDirectory', $uniqueName), $sessionDirectory);

        // bind the interface as reference to the application
        $namingDirectory->bind($uri = sprintf('php:global/%s/%s', $uniqueName, ApplicationInterface::IDENTIFIER), $this);

        // also bind an alias to the application
        /** @deprecated Also bind an alias to the application to ensure backwards compatibility */
        $namingDirectory->bindReference(sprintf('php:global/%s/Application', $uniqueName), $uri);
    }
public function prepare(ContainerInterface $container, ContextNode $contextNode)
    {

        // set the application configuration
        $this->contextNode = $contextNode;

        // load the unique application name + the naming directory
        $uniqueName = $this->getUniqueName();
        $namingDirectory = $this->getNamingDirectory();

        // create subdirectories for the application and the logger
        $namingDirectory->createSubdirectory(sprintf('php:global/%s', $uniqueName));
        $namingDirectory->createSubdirectory(sprintf('php:global/log/%s', $uniqueName));

        // create the applications 'env' + 'env/persistence' directory the beans + persistence units will be bound to
        $namingDirectory->createSubdirectory(sprintf('php:env/%s', $uniqueName));
        $namingDirectory->createSubdirectory(sprintf('php:global/%s/env', $uniqueName));
        $namingDirectory->createSubdirectory(sprintf('php:global/%s/env/persistence', $uniqueName));

        // bind the directory containing the applications
        $namingDirectory->bind(sprintf('php:env/%s/appBase', $uniqueName), $container->getAppBase());

        // prepare the application specific directories
        $webappPath = sprintf('%s/%s', $this->getAppBase(), $this->getName());
        $tmpDirectory = sprintf('%s/%s', $container->getTmpDir(), $this->getName());
        $dataDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::DATA), '/'));
        $cacheDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::CACHE), '/'));
        $sessionDirectory = sprintf('%s/%s', $tmpDirectory, ltrim($contextNode->getParam(DirectoryKeys::SESSION), '/'));

        // prepare the application specific environment variables
        $namingDirectory->bind(sprintf('php:env/%s/webappPath', $uniqueName), $webappPath);
        $namingDirectory->bind(sprintf('php:env/%s/tmpDirectory', $uniqueName), $tmpDirectory);
        $namingDirectory->bind(sprintf('php:env/%s/dataDirectory', $uniqueName), $dataDirectory);
        $namingDirectory->bind(sprintf('php:env/%s/cacheDirectory', $uniqueName), $cacheDirectory);
        $namingDirectory->bind(sprintf('php:env/%s/sessionDirectory', $uniqueName), $sessionDirectory);

        // bind the interface as reference to the application
        $namingDirectory->bind($uri = sprintf('php:global/%s/%s', $uniqueName, ApplicationInterface::IDENTIFIER), $this);

        // also bind an alias to the application
        /** @deprecated Also bind an alias to the application to ensure backwards compatibility */
        $namingDirectory->bindReference(sprintf('php:global/%s/Application', $uniqueName), $uri);
    }
public function prepare ( ContainerInterface $ container , ContextNode $ contextNode ) { // set the application configuration $ this -> contextNode = $ contextNode ; // load the unique application name + the naming directory $ uniqueName = $ this -> getUniqueName ( ) ; $ namingDirectory = $ this -> getNamingDirectory ( ) ; // create subdirectories for the application and the logger $ namingDirectory -> createSubdirectory ( sprintf ( 'php:global/%s' , $ uniqueName ) ) ; $ namingDirectory -> createSubdirectory ( sprintf ( 'php:global/log/%s' , $ uniqueName ) ) ; // create the applications 'env' + 'env/persistence' directory the beans + persistence units will be bound to $ namingDirectory -> createSubdirectory ( sprintf ( 'php:env/%s' , $ uniqueName ) ) ; $ namingDirectory -> createSubdirectory ( sprintf ( 'php:global/%s/env' , $ uniqueName ) ) ; $ namingDirectory -> createSubdirectory ( sprintf ( 'php:global/%s/env/persistence' , $ uniqueName ) ) ; // bind the directory containing the applications $ namingDirectory -> bind ( sprintf ( 'php:env/%s/appBase' , $ uniqueName ) , $ container -> getAppBase ( ) ) ; // prepare the application specific directories $ webappPath = sprintf ( '%s/%s' , $ this -> getAppBase ( ) , $ this -> getName ( ) ) ; $ tmpDirectory = sprintf ( '%s/%s' , $ container -> getTmpDir ( ) , $ this -> getName ( ) ) ; $ dataDirectory = sprintf ( '%s/%s' , $ tmpDirectory , ltrim ( $ contextNode -> getParam ( DirectoryKeys :: DATA ) , '/' ) ) ; $ cacheDirectory = sprintf ( '%s/%s' , $ tmpDirectory , ltrim ( $ contextNode -> getParam ( DirectoryKeys :: CACHE ) , '/' ) ) ; $ sessionDirectory = sprintf ( '%s/%s' , $ tmpDirectory , ltrim ( $ contextNode -> getParam ( DirectoryKeys :: SESSION ) , '/' ) ) ; // prepare the application specific environment variables $ namingDirectory -> bind ( sprintf ( 'php:env/%s/webappPath' , $ uniqueName ) , $ webappPath ) ; $ namingDirectory -> bind ( sprintf ( 'php:env/%s/tmpDirectory' , $ uniqueName ) , $ tmpDirectory ) ; $ namingDirectory -> bind ( sprintf ( 'php:env/%s/dataDirectory' , $ uniqueName ) , $ dataDirectory ) ; $ namingDirectory -> bind ( sprintf ( 'php:env/%s/cacheDirectory' , $ uniqueName ) , $ cacheDirectory ) ; $ namingDirectory -> bind ( sprintf ( 'php:env/%s/sessionDirectory' , $ uniqueName ) , $ sessionDirectory ) ; // bind the interface as reference to the application $ namingDirectory -> bind ( $ uri = sprintf ( 'php:global/%s/%s' , $ uniqueName , ApplicationInterface :: IDENTIFIER ) , $ this ) ; // also bind an alias to the application /** @deprecated Also bind an alias to the application to ensure backwards compatibility */ $ namingDirectory -> bindReference ( sprintf ( 'php:global/%s/Application' , $ uniqueName ) , $ uri ) ; }
Prepares the application with the specific data found in the
passed context node.

@param \AppserverIo\Psr\ApplicationServer\ContainerInterface $container   The container instance bind the application to
@param \AppserverIo\Appserver\Core\Api\Node\ContextNode      $contextNode The application configuration

@return void
Prepares the application with the specific data found in the passed context node .