예제 #1
0
 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = Yaml::load($this->file);
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addPropertyConstraint($property, $constraint);
                 }
             }
         }
         if (isset($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addGetterConstraint($getter, $constraint);
                 }
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Loads a Yaml file.
  *
  * @param string $file A Yaml file path
  * @param string $type The resource type
  *
  * @return RouteCollection A RouteCollection instance
  *
  * @throws \InvalidArgumentException When route can't be parsed
  */
 public function load($file, $type = null)
 {
     $path = $this->locator->locate($file);
     $config = Yaml::load($path);
     $collection = new RouteCollection();
     $collection->addResource(new FileResource($path));
     // empty file
     if (null === $config) {
         $config = array();
     }
     // not an array
     if (!is_array($config)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $file));
     }
     foreach ($config as $name => $config) {
         $config = $this->normalizeRouteConfig($config);
         if (isset($config['resource'])) {
             $type = isset($config['type']) ? $config['type'] : null;
             $prefix = isset($config['prefix']) ? $config['prefix'] : null;
             $this->setCurrentDir(dirname($path));
             $collection->addCollection($this->import($config['resource'], $type, false, $file), $prefix);
         } elseif (isset($config['pattern'])) {
             $this->parseRoute($collection, $name, $config, $path);
         } else {
             throw new \InvalidArgumentException(sprintf('Unable to parse the "%s" route.', $name));
         }
     }
     return $collection;
 }
예제 #3
0
 /**
  * Load configuration for a given command.
  * Loading happens only once, after that cached info is returned
  *
  * @param string $file  Config file path
  *
  * @return array Array of loaded config data
  */
 private function load($file)
 {
     if (null === $this->command) {
         $this->command = Yaml::load($file);
     }
     return $this->command;
 }
예제 #4
0
 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = Yaml::load($resource);
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
예제 #5
0
파일: Parser.php 프로젝트: ntulip/phrozn
 /**
  * Create phrozn command 
  *
  * @param array $paths Folder paths
  */
 public function __construct($paths)
 {
     // load main config
     $config = Yaml::load($paths['configs'] . 'phrozn.yml');
     parent::__construct($config['command']);
     $this->configureCommand($paths, $config); // load all necessary sub-commands
 }
예제 #6
0
 /**
  * Create runner
  *
  * @param \Phrozn\Autoloader $loader Instance of auto-loader
  * @param array $paths Folder paths
  */
 public function __construct($loader)
 {
     $this->paths = $loader->getPaths();
     $this->loader = $loader;
     // load main config
     $this->config = Yaml::load($this->paths['configs'] . 'phrozn.yml');
 }
예제 #7
0
 /**
  * @throws InvalidArgumentException from sfYaml::load
  * @throws Zend_Config_Exception
  * @param string $filename
  * @param boolean $allowModifications
  */
 public function __construct($filename, $allowModifications = false)
 {
     $this->filename = $filename;
     $this->checkIfFilenameIsFile();
     $content = SymfonyYaml::load($this->filename);
     if (is_null($content)) {
         $content = array();
     }
     parent::__construct($content, $allowModifications);
 }
예제 #8
0
 public function __construct()
 {
     parent::__construct();
     //Load Configuration
     $locator = new FileLocator(CFG_PATH);
     $this->setConfig(Yaml::load($locator->locate('config.yml')));
     //Load Extensions
     $this->loadExtensions();
     //Add template globals
     $this->defineTemplateGlobals();
 }
예제 #9
0
파일: Config.php 프로젝트: ntulip/phrozn
 /**
  * Setup config aggregator
  *
  * @param string $path Path to config folder
  *
  * @return
  */
 public function __construct($path)
 {
     $dir = new \DirectoryIterator($path);
     foreach ($dir as $item) {
         if ($item->isFile()) {
             if (substr($item->getBasename(), -3) === 'yml') {
                 $this->configs[$item->getBasename('.yml')] = Yaml::load($item->getRealPath());
             }
         }
     }
     $this->updatePaths(); // make sure that config.yml paths are absolute
 }
예제 #10
0
 /**
  * Loads the sitemap tree from config or cache
  * If loading from config, caches the result
  *
  * @return NodePub\Navigation\SitemapTree
  */
 public function load()
 {
     $sitemapTree = new SitemapTree('root');
     $sitemapTree->setIsRoot(true);
     $cache = new SitemapCache($this->cacheFile);
     if ($serializedArray = $cache->load()) {
         $sitemapTree->unserialize($serializedArray);
     } elseif (is_file($this->configFile)) {
         $sitemapTree = $this->expandChildNodes($parent, Yaml::load($this->configFile));
         $cache->cacheSerializedArray($sitemapTree->serialize());
     }
     return $sitemapTree;
 }
예제 #11
0
 /**
  * {@inheritdoc}
  */
 public function load($resource, $locale, $domain = 'messages')
 {
     $messages = Yaml::load($resource);
     // empty file
     if (null === $messages) {
         $messages = array();
     }
     // not an array
     if (!is_array($messages)) {
         throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $resource));
     }
     $catalogue = parent::load($messages, $locale, $domain);
     $catalogue->addResource(new FileResource($resource));
     return $catalogue;
 }
예제 #12
0
 /**
  * {@inheritDoc}
  */
 public function loadClassMetadata(ClassMetadata $metadata)
 {
     if (null === $this->classes) {
         $this->classes = Yaml::load($this->file);
         // empty file
         if (null === $this->classes) {
             return false;
         }
         // not an array
         if (!is_array($this->classes)) {
             throw new \InvalidArgumentException(sprintf('The file "%s" must contain a YAML array.', $this->file));
         }
         if (isset($this->classes['namespaces'])) {
             foreach ($this->classes['namespaces'] as $prefix => $namespace) {
                 $this->namespaces[$prefix] = $namespace;
             }
             unset($this->classes['namespaces']);
         }
     }
     // TODO validation
     if (isset($this->classes[$metadata->getClassName()])) {
         $yaml = $this->classes[$metadata->getClassName()];
         if (isset($yaml['constraints'])) {
             foreach ($this->parseNodes($yaml['constraints']) as $constraint) {
                 $metadata->addConstraint($constraint);
             }
         }
         if (isset($yaml['properties'])) {
             foreach ($yaml['properties'] as $property => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addPropertyConstraint($property, $constraint);
                 }
             }
         }
         if (isset($yaml['getters'])) {
             foreach ($yaml['getters'] as $getter => $constraints) {
                 foreach ($this->parseNodes($constraints) as $constraint) {
                     $metadata->addGetterConstraint($getter, $constraint);
                 }
             }
         }
         return true;
     }
     return false;
 }
 /**
  * Get an array of ClassMetadataInfo instances from the passed
  * Doctrine 1 schema
  *
  * @return array $metadatas  An array of ClassMetadataInfo instances
  */
 public function getMetadata()
 {
     $schema = array();
     foreach ($this->_from as $path) {
         if (is_dir($path)) {
             $files = glob($path . '/*.yml');
             foreach ($files as $file) {
                 $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($file));
             }
         } else {
             $schema = array_merge($schema, (array) \Symfony\Component\Yaml\Yaml::load($path));
         }
     }
     $metadatas = array();
     foreach ($schema as $className => $mappingInformation) {
         $metadatas[] = $this->_convertToClassMetadataInfo($className, $mappingInformation);
     }
     return $metadatas;
 }
 /**
  * @inheritdoc
  */
 protected function _load($file)
 {
     $array = Yaml::load($file);
     if (isset($array['name'])) {
         $this->setName($array['name']);
     }
     if (isset($array['table_name'])) {
         $this->setMigrationsTableName($array['table_name']);
     }
     if (isset($array['migrations_namespace'])) {
         $this->setMigrationsNamespace($array['migrations_namespace']);
     }
     if (isset($array['migrations_directory'])) {
         $migrationsDirectory = $this->_getDirectoryRelativeToFile($file, $array['migrations_directory']);
         $this->setMigrationsDirectory($migrationsDirectory);
         $this->registerMigrationsFromDirectory($migrationsDirectory);
     }
     if (isset($array['migrations']) && is_array($array['migrations'])) {
         foreach ($array['migrations'] as $migration) {
             $this->registerMigration($migration['version'], $migration['class']);
         }
     }
 }
예제 #15
0
 protected function loadFile($file)
 {
     return $this->validate(Yaml::load($file), $file);
 }
예제 #16
0
파일: Commands.php 프로젝트: ntulip/phrozn
 /**
  * Load configuration for a given command.
  * Loading happens only once, after that cached info is returned
  *
  * @param string $file  Config file name
  *
  * @return array Array of loaded config data
  */
 private function load($file)
 {
     if (!isset($this->commands[$file])) {
         $this->commands[$file] = Yaml::load($file);
     }
     return $this->commands[$file];
 }
예제 #17
0
            }
        }
    }
}
// Make sure env is a valid value (this also protects against directory traversal attacks)
if (!in_array($env, array("production", "staging", "development", "test"))) {
    throw new \Exception("The environment must be production, staging, development or test");
}
define('APP_PATH', ROOT_PATH . DIRECTORY_SEPARATOR . "app" . DIRECTORY_SEPARATOR . $appName);
if (!file_exists(APP_PATH)) {
    if (php_sapi_name() != "cli") {
        throw new \Exception("The application '{$appName}' does not exist.  Generate it using the flextrine console tool (flextrine app:create <app_name>)");
    }
} else {
    // Load the application specific configuration file
    $appConfigFile = APP_PATH . "/config/" . $env . ".yml";
    if (!file_exists($appConfigFile)) {
        throw new \Exception("The configuration file for this application was not found (" . $appConfigFile . ")");
    }
    $appConfig = Yaml::load($appConfigFile);
    Zend_Registry::set("appConfig", $appConfig);
    // We need an extra class loader for the entities and services directory themselves; use empty namespace as there could be anything in here
    $entityClassLoader = new ClassLoader(null, APP_PATH . DIRECTORY_SEPARATOR . $appConfig["directories"]["entities"]);
    $entityClassLoader->register();
    // Create the Doctrine EntityManager
    Zend_Registry::set("em", Flextrine\Factory\EntityManagerFactory::create(Zend_Registry::get("appConfig")));
    // If acls are enabled create the Acl instance
    if ($appConfig["acl"]["enable"]) {
        Zend_Registry::set("acl", Flextrine\Factory\AclFactory::create(Zend_Registry::get("appConfig")));
    }
}
예제 #18
0
 * obtain it through the world-wide-web, please send an email
 * to licensing@litecommerce.com so we can send you a copy immediately.
 * 
 * PHP version 5.3.0
 * 
 * @category  LiteCommerce
 * @author    Creative Development LLC <*****@*****.**> 
 * @copyright Copyright (c) 2011 Creative Development LLC <*****@*****.**>. All rights reserved
 * @license   http://opensource.org/licenses/osl-3.0.php Open Software License (OSL 3.0)
 * @link      http://www.litecommerce.com/
 */
return function () {
    // Load missing currency's translations
    $yamlFile = __DIR__ . LC_DS . 'currencies.yaml';
    if (\Includes\Utils\FileManager::isFileReadable($yamlFile)) {
        $data = \Symfony\Component\Yaml\Yaml::load($yamlFile);
        // Import new and update old currencies
        $repo = \XLite\Core\Database::getRepo('XLite\\Model\\Currency');
        foreach ($data['XLite\\Model\\Currency'] as $cell) {
            $currency = $repo->findOneBy(array('code' => $cell['code']));
            if ($currency) {
                foreach ($cell['translations'] as $t) {
                    $translation = $currency->getTranslation($t['code']);
                    $translation->setName($t['name']);
                    if (!$translation->getLabelId()) {
                        \XLite\Core\Database::getEM()->persist($translation);
                    }
                }
            }
        }
        \XLite\Core\Database::getEM()->flush();
예제 #19
0
 /**
  * Import table's from the yml files
  */
 function createTablesFromYaml()
 {
     $ymlDirectory = $this->getDirectory(false) . '/Model/Yaml';
     $em = \Env::get('cx')->getDb()->getEntityManager();
     $classes = array();
     foreach (glob($ymlDirectory . '/*.yml') as $yml) {
         $ymlArray = \Symfony\Component\Yaml\Yaml::load($yml);
         $classes[] = $em->getClassMetadata(key($ymlArray));
     }
     $scm = new \Doctrine\ORM\Tools\SchemaTool($em);
     $scm->createSchema($classes);
 }
예제 #20
0
 private function getAppConfig()
 {
     if (null === $this->appConfig) {
         $path = Loader::getInstance()->getPath('configs') . '/phrozn.yml';
         $this->appConfig = Yaml::load(file_get_contents($path));
     }
     return $this->appConfig;
 }
예제 #21
0
					$unit->getPrefixes()->add($siPrefix);		
				}
			}
		}
	}
	
	PartKeepr::getEM()->persist($unit);
	$aUnits[] = $unit;
	
}

PartKeepr::getEM()->flush();


/* Add manufacturers and IC logos */
$data = \Symfony\Component\Yaml\Yaml::load("../setup/data/manufacturers/manufacturers.yaml");

$aManufacturers = array();
$aDistributors = array();

foreach ($data as $mfgname => $logos) {
	$manufacturer = new Manufacturer();
	$manufacturer->setName($mfgname);
	
	PartKeepr::getEM()->persist($manufacturer);
	$aManufacturers[] = $manufacturer;
	
	foreach ($logos as $logo) {
		$mfglogo = new ManufacturerICLogo();
		$mfglogo->setManufacturer($manufacturer);
		$mfglogo->replace("../setup/data/manufacturers/images/".$logo);
예제 #22
0
 /**
  * Loads the configuration from a yaml file
  * 
  * @param InputInterface $input
  * @throws Exception
  */
 protected function loadConfig(InputInterface $input)
 {
     $configFile = $input->getOption('config');
     if (file_exists($configFile)) {
         $config = Yaml::load($configFile);
         $this->harvestConfig = $config['harvest'];
         $this->settingsConfig = $config['settings'];
         $this->budgetConfig = $config['budget'];
         $this->input = $input;
     } else {
         throw new \Exception(sprintf('Missing configuration file %s', $configFile));
     }
 }
예제 #23
0
 /**
  * Get site configuration
  *
  * @return array
  */
 public function getSiteConfig()
 {
     if (null === $this->siteConfig) {
         $configFile = realpath($this->getInputDir() . '/config.yml');
         $this->siteConfig = Yaml::load($configFile);
     }
     return $this->siteConfig;
 }
 /**
  * Create a navigation container from a YAML config file.
  *
  * @param RouterInterface $router
  * @param Request $request
  * @param string $configFile
  * @return Navigation
  */
 public static function factory(RouterInterface $router, Request $request, $configFile)
 {
     $pages = \Symfony\Component\Yaml\Yaml::load($configFile);
     return new self($router, $request, $pages);
 }
예제 #25
0
 /**
  * Loads information from YAML configuration file.
  *
  * @param   string  $configFile     path to the config file
  * @param   string  $profile        name of the config profile to use
  *
  * @return  array
  */
 protected function loadConfigurationFile($configFile, $profile = 'default')
 {
     $config = Yaml::load($configFile);
     $resultConfig = isset($config['default']) ? $config['default'] : array();
     if ('default' !== $profile && isset($config[$profile])) {
         $resultConfig = $this->configMergeRecursiveWithOverwrites($resultConfig, $config[$profile]);
     }
     if (isset($config['imports'])) {
         foreach ($config['imports'] as $path) {
             if (!file_exists($path) && file_exists(getcwd() . DIRECTORY_SEPARATOR . $path)) {
                 $path = getcwd() . DIRECTORY_SEPARATOR . $path;
             }
             if (!file_exists($path)) {
                 foreach (explode(':', get_include_path()) as $libPath) {
                     if (file_exists($libPath . DIRECTORY_SEPARATOR . $path)) {
                         $path = $libPath . DIRECTORY_SEPARATOR . $path;
                         break;
                     }
                 }
             }
             $resultConfig = $this->configMergeRecursiveWithOverwrites($resultConfig, $this->loadConfigurationFile($path, $profile));
         }
     }
     return $resultConfig;
 }
예제 #26
0
 /**
  * Loads a Yaml file.
  *
  * @param string $file A Yaml file path
  *
  * @return array
  */
 protected function loadFile($file)
 {
     return Yaml::load($file);
 }
예제 #27
0
 /**
  * Loads a YAML file.
  *
  * @param string $file
  * @return array The file content
  */
 private function loadFile($file)
 {
     return $this->validate(Yaml::load($file), $file);
 }
예제 #28
0
 private function getCommandMeta()
 {
     if (null === $this->commandMeta) {
         $config = $this->getConfig();
         $this->commandMeta = Yaml::load($config['paths']['configs'] . 'phrozn.yml');
     }
     return $this->commandMeta;
 }
예제 #29
0
 /**
  * {@inheritDoc}
  */
 protected function _loadMappingFile($file)
 {
     return \Symfony\Component\Yaml\Yaml::load($file);
 }
예제 #30
0
 public function fullConfigurationProvider()
 {
     $yaml = Yaml::load(__DIR__ . '/Fixtures/config/yml/full.yml');
     $yaml = $yaml['doctrine_mongo_db'];
     return array(array($yaml));
 }