/**
  * @return void
  */
 public static function finishInstallation(Event\Type\System\ExtensionInstall $event)
 {
     $app = $event->getCurrentNode()->getRootNode();
     $composer_lock = FileHelper::create($app->getDirectory(), 'composer.lock');
     $composer_lock_json = $composer_lock->readJson();
     foreach ($composer_lock_json['packages'] as &$pkg_entry) {
         if ($pkg_entry['name'] == $event->getComposerPackageName() && true === $event->getResult()) {
             // Mark extension as installed
             $pkg_entry['installed'] = 'yes';
             $composer_lock->writeJson($composer_lock_json, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES);
         }
     }
 }
示例#2
0
 /**
  * @return array
  */
 protected function scanPhpDefinitions($targetDir, \Closure $callback, $exclude = [], $name = '*.php')
 {
     $result = array();
     $loc = FileHelper::create($this->getPackage()->getDirectory(), $targetDir);
     if (!$loc->dirExists()) {
         return $result;
     }
     $phpFiles = Finder::create()->findByFilename($name, $loc->toString())->exclude($exclude);
     foreach ($phpFiles as $file) {
         $className = Parser::loadFromFile($file->getRealpath())->parseClass();
         $interface = Parser::loadFromFile($file->getRealpath())->parseInterface();
         $callbackResult = $callback($className, $interface, $file);
         if ($callbackResult !== null) {
             $result[] = $callbackResult;
         }
     }
     return $result;
 }
示例#3
0
<?php

namespace PHPCrystal\PHPCrystalTest;

use PHPCrystal\PHPCrystal\Component\Filesystem\FileHelper;
require __DIR__ . '/../vendor/autoload.php';
ini_set('error_reporting', E_ALL);
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
FileHelper::addAlias('app', __DIR__);
示例#4
0
$this->set('storage', Facade\Filesystem::create());
// if set to true does not accept uninitialized session ID
$this->set('use_strict_mode', true);
$this->set('use_trans_sid', false);
$this->set('save_path', sys_get_temp_dir());
$this->set('name', 'SID');
$this->set('cookie_lifetime', 0);
$this->set('cookie_path', '/');
$this->set('cookie_domain', $this->getHostname());
$this->set('cookie_httponly', true);
$this->set('auto_start', true);
$this->set('gc_probability', 1);
$this->set('gc_divisor', 100);
$this->set('gc_maxlifetime', 1800);
$this->closeSection();
$this->serviceSection('cache');
$this->set('driver', Facade\Memcached::create())->_->addServer('localhost')->setOption(\Memcached::OPT_LIBKETAMA_COMPATIBLE, true);
$this->closeSection();
// Doctrine ORM
$this->serviceSection('doctrine');
$this->set('proxyDir', FileHelper::create('@cache/doctrine/proxy'));
// directory for proxy class files
$this->set('proxyNamespace', 'Model\\Doctrine\\Proxy\\');
$this->set('modelNamespace', 'Model\\Doctrine\\');
$this->set('modelPaths', [FileHelper::create('@app/Model/Physical')]);
$this->set('entityPaths', [FileHelper::create('@app', 'src', 'Model', 'Entity2')]);
$this->set('dbal.autocommit', false);
$this->set('dbal.driver', 'pdo_mysql');
$this->closeSection();
// End of the main config section
$this->closeSection();
示例#5
0
 /**
  * @return $this
  */
 public function addPathAlias($alias, $pathname, $allowOverride = true)
 {
     FileHelper::addAlias($alias, $pathname, $allowOverride);
     return $this;
 }
示例#6
0
 /**
  * @return void
  */
 public function addExtensionsToAutoload()
 {
     $composer_lock = FileHelper::create('@app/composer.lock');
     if (!$composer_lock->fileExists()) {
         return;
     }
     $composer_json = $composer_lock->readJson();
     foreach ($composer_json['packages'] as $pkgInfo) {
         $pkgName = $pkgInfo['name'];
         $pkgBootstrap = FileHelper::create('@app/vendor/', $pkgName, 'bootstrap.php');
         if (!$pkgBootstrap->fileExists()) {
             continue;
         }
         $pkg_instance = $pkgBootstrap->_require();
         if (!$pkg_instance instanceof AbstractExtension || $pkg_instance->getDisableAutoloadFlag()) {
             continue;
         }
         $this->data['extensions'][] = new MetaExtension($pkgBootstrap->getDirname());
     }
 }
示例#7
0
 public function testAppAlias()
 {
     $appPath = FileHelper::create('@app');
     $this->assertEquals(realpath(__DIR__ . '/../../../'), $appPath->toString());
 }
示例#8
0
 /**
  * @return $this
  */
 public static function createFromFile($filename)
 {
     $requestStr = FileHelper::create($filename)->getFileContent();
     $request = static::createFromString($requestStr);
     if ($request->isPost()) {
         $postRawData = array();
         foreach (explode('&', rawurldecode($request->getContent())) as $dataItem) {
             $keyValue = explode('=', $dataItem);
             $postRawData[$keyValue[0]] = $keyValue[1];
         }
         $request->setPostInput(Input::createFromArray($postRawData));
     }
     $cookieHeader = $request->getHeaders()->get('Cookie');
     $cookies = $cookieHeader instanceof \Zend\Http\Header\Cookie ? $cookieHeader->getArrayCopy() : [];
     $request->setCookieInput(Input::createFromArray($cookies));
     return $request;
 }
示例#9
0
 /**
  * Loads package configuration file
  * 
  * @return void
  */
 protected final function loadConfigFile()
 {
     $context = $this->getApplication()->getCurrentEvent()->createContext();
     $this->config = FileHelper::create($this->getDirectory(), 'config.php')->requireIfExists($context);
 }
 /**
  * @return 
  */
 protected function addPathAliases()
 {
     FileHelper::addAlias('cache', '@app/cache');
     FileHelper::addAlias('web', '@app/public_html');
     FileHelper::addAlias('template', '@app/resources/template');
     FileHelper::addAlias('tmp', '@app/tmp');
 }
示例#11
0
<?php

namespace PHPCrystal\PHPCrystal;

use PHPCrystal\PHPCrystal\Component\Filesystem\FileHelper;
use PHPCrystal\PHPCrystal\Facade;
$this->set('env', 'prod');
$this->openSection('app');
$this->set('hostname', 'locahost');
$this->closeSection();
$this->openSection('phpcrystal.core');
$this->set('twig.debug', true);
$this->set('twig.auto_reaload', true);
$this->set('twig.cache', FileHelper::create('@cache'));
$this->set('twig.templates', FileHelper::create('@template'));
$this->set('twig.autoescape', true);
$this->closeSection();
// Database common settings.
$this->openSection('phpcrystal.phpcrystal.database');
$this->set('driver', 'pdo_mysql');
$this->set('user', 'root');
$this->set('password', '');
$this->set('dbname', null);
$this->set('charset', 'UTF8');
$this->closeSection();
$this->serviceSection('phpcrystal.security_guard');
$this->set('enabled', true);
$this->set('csrf-token-cookie-name', 'csrf-token');
$this->set('csrf-token-header-field-name', 'X-Csrf-Token');
$this->set('csrf-token-secret-key', mt_rand(0, mt_getrandmax()));
$this->closeSection();