本文整理汇总了PHP中Doctrine_Lib类的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Lib类的具体用法?PHP Doctrine_Lib怎么用?PHP Doctrine_Lib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Doctrine_Lib类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的PHP代码示例。
示例1: __construct
public function __construct(array $options = array())
{
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
if (!$this->_options['onlyOwnable']) {
$this->_plugin = new Doctrine_Guardable($this->_options);
}
}
开发者ID:everzet,项目名称:sfDoctrineObjectGuardPlugin,代码行数:7,代码来源:Guardable.php
示例2: __construct
/**
* Constructor for Locatable Template
*
* @param array $options
*
* @return void
*/
public function __construct(array $options = array())
{
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
if (!$this->_options['fields']) {
throw new sfException('The Geolocatable Behavior requires the "fields" option to be set in your schema');
}
}
开发者ID:jwegner,项目名称:csDoctrineActAsGeolocatablePlugin,代码行数:14,代码来源:Geolocatable.php
示例3: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$config = $this->getCliConfig();
$pluginSchemaDirectories = glob(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR . '*' . DIRECTORY_SEPARATOR . 'config' . DIRECTORY_SEPARATOR . 'doctrine');
$pluginSchemas = sfFinder::type('file')->name('*.yml')->in($pluginSchemaDirectories);
$tmpPath = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp';
if (!file_exists($tmpPath)) {
Doctrine_Lib::makeDirectories($tmpPath);
}
foreach ($pluginSchemas as $schema) {
$schema = str_replace('/', DIRECTORY_SEPARATOR, $schema);
$plugin = str_replace(sfConfig::get('sf_plugins_dir') . DIRECTORY_SEPARATOR, '', $schema);
$e = explode(DIRECTORY_SEPARATOR, $plugin);
$plugin = $e[0];
$name = basename($schema);
$tmpSchemaPath = $tmpPath . DIRECTORY_SEPARATOR . $plugin . '-' . $name;
$models = Doctrine_Parser::load($schema, 'yml');
if (!isset($models['package'])) {
$models['package'] = $plugin . '.lib.model.doctrine';
}
Doctrine_Parser::dump($models, 'yml', $tmpSchemaPath);
}
$import = new Doctrine_Import_Schema();
$import->setOption('generateBaseClasses', true);
$import->setOption('generateTableClasses', true);
$import->setOption('packagesPath', sfConfig::get('sf_plugins_dir'));
$import->setOption('packagesPrefix', 'Plugin');
$import->setOption('suffix', '.class.php');
$import->setOption('baseClassesDirectory', 'generated');
$import->setOption('baseClassName', 'sfDoctrineRecord');
$import->importSchema(array($tmpPath, $config['yaml_schema_path']), 'yml', $config['models_path']);
$this->dispatcher->notify(new sfEvent($this, 'command.log', array($this->formatter->formatSection('doctrine', 'Generated models successfully'))));
}
开发者ID:silky,项目名称:littlesis,代码行数:36,代码来源:sfDoctrineBuildModelTask.class.php
示例4: __construct
/**
* __construct
*
* @param string $options
* @return void
*/
public function __construct(array $options = array())
{
$dispatcher = ProjectConfiguration::getActive()->getEventDispatcher();
$dispatcher->connect('commentable.add_commentable_class', array($this, 'getCommentables'));
$options['generatePath'] = sfConfig::get('sf_lib_dir') . '/model/doctrine/sfCommentsPlugin';
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
}
开发者ID:bshaffer,项目名称:Symplist,代码行数:13,代码来源:CommentLinkGenerator.class.php
示例5: setUp
/**
* Initialize the template
* @return void
*/
public function setUp()
{
// TODO: cache compiled options since they do not change frequently
$options = $this->options;
// merge in special soft delete options
if ($this->getInvoker()->getTable()->hasTemplate('SoftDelete')) {
$options = Doctrine_Lib::arrayDeepMerge($options, $this->optionsWhenSoftDeleteIsEnabled);
}
// merge in options defined in the schema
$options = Doctrine_Lib::arrayDeepMerge($options, $this->_options);
// merge in default options for credentials
foreach ($options['credentials'] as $credential => $cOptions) {
$options['credentials'][$credential] = array_merge($this->credentialOptions, $cOptions);
}
// merge in default options for fields
foreach ($options['fields'] as $fieldName => $fieldOptions) {
$fieldOptions = array_merge($this->fieldOptions, $fieldOptions);
if (!is_string($fieldOptions['view']) && !is_null($fieldOptions['view']) && $fieldOptions['view'] !== false) {
throw new InvalidArgumentException(sprintf('view credential has an invalid type for field %s.', $fieldName));
}
if (!is_string($fieldOptions['edit']) && !is_null($fieldOptions['edit']) && $fieldOptions['edit'] !== false) {
throw new InvalidArgumentException(sprintf('edit credential has an invalid type for field %s.', $fieldName));
}
if (!is_string($fieldOptions['create']) && !is_null($fieldOptions['create']) && $fieldOptions['create'] !== false) {
throw new InvalidArgumentException(sprintf('create credential has an invalid type for field %s.', $fieldName));
}
$options['fields'][$fieldName] = $fieldOptions;
}
$options['credentials'] = $this->copyRelationsToEachSide($options['credentials']);
$this->options = $options;
}
开发者ID:schmittjoh,项目名称:jmsDoctrinePlugin,代码行数:35,代码来源:Credentialable.class.php
示例6: __construct
public function __construct(array $options = array())
{
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
if (!isset($this->_options['connection'])) {
$this->_options['connection'] = Doctrine_Manager::connection();
}
}
开发者ID:pierswarmers,项目名称:rtCorePlugin,代码行数:7,代码来源:rtCommentTemplate.class.php
示例7: execute
/**
* @see sfTask
*/
protected function execute($arguments = array(), $options = array())
{
$this->logSection('doctrine', 'generating model classes');
$config = $this->getCliConfig();
$this->_checkForPackageParameter($config['yaml_schema_path']);
$tmpPath = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp';
if (!file_exists($tmpPath)) {
Doctrine_Lib::makeDirectories($tmpPath);
}
$plugins = $this->configuration->getPlugins();
foreach ($this->configuration->getAllPluginPaths() as $plugin => $path) {
if (!in_array($plugin, $plugins)) {
continue;
}
$schemas = sfFinder::type('file')->name('*.yml')->in($path . '/config/doctrine');
foreach ($schemas as $schema) {
$tmpSchemaPath = $tmpPath . DIRECTORY_SEPARATOR . $plugin . '-' . basename($schema);
$models = Doctrine_Parser::load($schema, 'yml');
if (!isset($models['package'])) {
$models['package'] = $plugin . '.lib.model.doctrine';
$models['package_custom_path'] = $path . '/lib/model/doctrine';
}
Doctrine_Parser::dump($models, 'yml', $tmpSchemaPath);
}
}
$options = array('generateBaseClasses' => true, 'generateTableClasses' => true, 'packagesPath' => sfConfig::get('sf_plugins_dir'), 'packagesPrefix' => 'Plugin', 'suffix' => '.class.php', 'baseClassesDirectory' => 'base', 'baseClassName' => 'sfDoctrineRecord');
$options = array_merge($options, sfConfig::get('doctrine_model_builder_options', array()));
$import = new Doctrine_Import_Schema();
$import->setOptions($options);
$import->importSchema(array($tmpPath, $config['yaml_schema_path']), 'yml', $config['models_path']);
}
开发者ID:yasirgit,项目名称:afids,代码行数:34,代码来源:sfDoctrineBuildModelTask.class.php
示例8: setOption
/**
* setOption
* sets an option in order to allow flexible listener chaining
*
* @param mixed $name the name of the option to set
* @param mixed $value the value of the option
*/
public function setOption($name, $value = null)
{
if (is_array($name)) {
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $name);
} else {
$this->_options[$name] = $value;
}
}
开发者ID:densem-2013,项目名称:exikom,代码行数:15,代码来源:Chain.php
示例9: fill
public function fill($name, $values = array())
{
$formValues = Doctrine_Lib::arrayDeepMerge($this->getFormValues($name), $values);
foreach ($formValues as $key => $value) {
$this->setDefaultField($key, $value);
}
return $this->getObjectToReturn();
}
开发者ID:bshaffer,项目名称:Symfony-Snippets,代码行数:8,代码来源:csTesterForm.class.php
示例10: __construct
/**
* __construct
*
* @param string $array
* @return null
*/
public function __construct(array $options = array())
{
$this->_options = Doctrine_Lib::arrayDeepMerge($this->getOptions(), $options);
$this->invokerNamespace = sprintf('%s/%s', __CLASS__, sfCacheTaggingToolkit::generateVersion());
$versionColumn = $this->getOption('versionColumn');
if (!is_string($versionColumn) || 0 >= strlen($versionColumn)) {
throw new sfConfigurationException(sprintf('sfCacheTaggingPlugin: "%s" behaviors "versionColumn" ' . 'should be string and not empty, passed "%s"', sfCacheTaggingToolkit::TEMPLATE_NAME, (string) $versionColumn));
}
}
开发者ID:uniteddiversity,项目名称:policat,代码行数:15,代码来源:Cachetaggable.php
示例11: __construct
/**
* __construct
*
* @param array $options
* @return void
*/
public function __construct(array $options)
{
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
if (!isset($this->_options['analyzer'])) {
$this->_options['analyzer'] = new Doctrine_Search_Analyzer_Standard();
}
if (!isset($this->_options['connection'])) {
$this->_options['connection'] = Doctrine_Manager::connection();
}
}
开发者ID:walterfrs,项目名称:mladek,代码行数:16,代码来源:Search.php
示例12: testImport
public function testImport()
{
$this->dbh = new PDO('sqlite::memory:');
$this->dbh->exec('CREATE TABLE import_test_user (id INTEGER PRIMARY KEY, name TEXT)');
$this->conn = Doctrine_Manager::connection($this->dbh, 'tmp123');
$this->conn->import->importSchema('Import/_files', array('tmp123'));
$this->assertTrue(file_exists('Import/_files/ImportTestUser.php'));
$this->assertTrue(file_exists('Import/_files/generated/BaseImportTestUser.php'));
Doctrine_Lib::removeDirectories('Import/_files');
}
开发者ID:swk,项目名称:bluebox,代码行数:10,代码来源:ImportTestCase.php
示例13: __construct
/**
* __construct
*
* @param array $options
* @return void
*/
public function __construct(array $options)
{
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
if (!isset($this->_options['analyzer'])) {
$this->_options['analyzer'] = 'Doctrine_Search_Analyzer_Standard';
}
if (!isset($this->_options['analyzer_options'])) {
$this->_options['analyzer_options'] = array();
}
$this->_options['analyzer'] = new $this->_options['analyzer']($this->_options['analyzer_options']);
}
开发者ID:dennybrandes,项目名称:doctrine1,代码行数:17,代码来源:Search.php
示例14: writeTableClassDefinition
/**
* writeTableClassDefinition
*
* @return void
*/
public function writeTableClassDefinition(array $definition, $path, $options = array())
{
$className = $definition['tableClassName'];
$pos = strpos($className, "Model_");
$fileName = substr($className, $pos + 6) . $this->_suffix;
$writePath = $path . DIRECTORY_SEPARATOR . $fileName;
$content = $this->buildTableClassDefinition($className, $definition, $options);
Doctrine_Lib::makeDirectories(dirname($writePath));
Doctrine_Core::loadModel($className, $writePath);
if (!file_exists($writePath)) {
file_put_contents($writePath, $content);
}
}
开发者ID:lciolecki,项目名称:zf-doctrine,代码行数:18,代码来源:Builder.php
示例15: __construct
/**
* @param array $options
*
* options can contain:
*
* - string thumb_dir The directory to create the thumbnails in (relative to the file's dirname)
* - boolean on_demand Whether to create or not thumbnails on demand
* - boolean on_save Whether to create or not thumbnails on save
* - boolean strict Whether to allow other formats than those in 'formats'
* - array formats Default formats to create for on_save
*
* the 'formats' array should contain a list of formats per-field:
*
* array(
* 'media_id' => array('50x50')
* 'cover_image' => array('100x50')
* )
*/
public function __construct(array $options = array())
{
if (!class_exists('sfThumbnail')) {
throw new sfException('You need the sfThumbnailPlugin installed to use this template');
}
$app_config = array();
if (isset($options['config_key'])) {
if (null === ($app_config = sfConfig::get('app_' . $options['config_key'], null))) {
throw new sfException(sprintf('Could not find configuration in key "%s", maybe you forget a ".plugins" in your app.yml ?', $options['config_key']));
}
}
$this->options = Doctrine_Lib::arrayDeepMerge($this->options, $options, $app_config);
}
开发者ID:ubermuda,项目名称:sfDoctrineThumbnailablePlugin,代码行数:31,代码来源:DoctrineThumbnailable.class.php
示例16: testYmlImport
public function testYmlImport()
{
$path = dirname(__FILE__) . '/import_builder_test';
$import = new Doctrine_Import_Schema();
$import->importSchema('schema.yml', 'yml', $path);
if (!file_exists($path . '/SchemaTestUser.php')) {
$this->fail();
}
if (!file_exists($path . '/SchemaTestProfile.php')) {
$this->fail();
}
$this->assertEqual(Doctrine::getTable('AliasTest')->getFieldName('test_col'), 'test_col_alias');
Doctrine_Lib::removeDirectories($path);
}
开发者ID:swk,项目名称:bluebox,代码行数:14,代码来源:SchemaTestCase.php
示例17: setRoutingValue
public function setRoutingValue(array $values)
{
$this->info('setting routing.yml config values');
$path = sfConfig::get('sf_app_dir') . '/config/routing.yml';
$config = Doctrine_Lib::arrayDeepMerge(sfYaml::load($path), $values);
file_put_contents($path, sfYaml::dump($config));
sfToolkit::clearDirectory(sfConfig::get('sf_cache_dir'));
return $this;
}
开发者ID:romankallweit,项目名称:swingmachine,代码行数:14,代码来源:sfTestFunctionalHadori.class.php
示例18: __construct
/**
* Constructor for Markdown Template
*
* @param array $options
* @return void
* @author Brent Shaffer
*/
public function __construct(array $options = array())
{
if (!isset($options['fields'])) {
throw new sfException("Required parameter 'fields' not set in Doctrine Markdown");
}
$this->_options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
// Set markdown field names if they are not set by the user
foreach ($this->_options['fields'] as $key => $value) {
if (is_int($key)) {
unset($this->_options['fields'][$key]);
$this->_options['fields'][$value . '_html'] = $value;
}
}
}
开发者ID:bshaffer,项目名称:Symplist,代码行数:21,代码来源:MarkdownTemplate.class.php
示例19: testImportOfHieriarchyOfPluginGeneration
public function testImportOfHieriarchyOfPluginGeneration()
{
$yml = <<<END
---
WikiTest:
actAs:
I18n:
fields: [title, content]
actAs:
Versionable:
fields: [title, content]
Searchable:
fields: [title, content]
Sluggable:
fields: [title]
columns:
title: string(255)
content: string
END;
file_put_contents('wiki.yml', $yml);
$path = dirname(__FILE__) . '/tmp/import_builder_test';
$import = new Doctrine_Import_Schema();
$import->setOption('generateTableClasses', true);
$import->importSchema('wiki.yml', 'yml', $path);
// check that the plugin hierarchy will produce the right sql statements
// this is almost an end-to-end testing :-)
$models = Doctrine::loadModels($path, Doctrine::MODEL_LOADING_CONSERVATIVE);
$sql = $this->conn->export->exportClassesSql(array('WikiTest'));
$result = array(
0 => 'CREATE TABLE wiki_test_translation_version (id INTEGER, lang CHAR(2), title VARCHAR(255), content VARCHAR(2147483647), version INTEGER, PRIMARY KEY(id, lang, version))',
1 => 'CREATE TABLE wiki_test_translation_index (id INTEGER, lang CHAR(2), keyword VARCHAR(200), field VARCHAR(50), position INTEGER, PRIMARY KEY(id, lang, keyword, field, position))',
2 => 'CREATE TABLE wiki_test_translation (id INTEGER, title VARCHAR(255), content VARCHAR(2147483647), lang CHAR(2), version INTEGER, slug VARCHAR(255), PRIMARY KEY(id, lang))',
3 => 'CREATE TABLE wiki_test (id INTEGER PRIMARY KEY AUTOINCREMENT)',
4 => 'CREATE INDEX sluggable_idx ON wiki_test_translation (slug)',
);
foreach($sql as $idx => $req) {
$this->assertEqual($req, $result[$idx]);
}
Doctrine_Lib::removeDirectories($path);
unlink('wiki.yml');
}
开发者ID:prismhdd,项目名称:victorioussecret,代码行数:48,代码来源:PluginHierarchyTestCase.php
示例20: update
/**
* Update the existing schema.yml file with any new tables that were passed
* to the method.
*
* @param string $outputFile The full path of the current schema file
* @param array $connections An associative array of connections and their
* tables. See buildPHPModels
* @param array $options Any options to be passed to
* Doctrine_Import_Builder
* @return type
*/
public function update($outputFile, array $connections = array(), array $options = array())
{
try {
$directory = sys_get_temp_dir() . DIRECTORY_SEPARATOR . 'tmp_doctrine_models';
$options['generateBaseClasses'] = isset($options['generateBaseClasses']) ? $options['generateBaseClasses'] : false;
$models = $this->buildPHPModels($directory, $connections, $options);
if (empty($models) && !is_dir($directory)) {
throw new Exception('No models generated from your databases');
}
$this->generateYaml($outputFile, $directory, array(), Doctrine_Core::MODEL_LOADING_AGGRESSIVE);
Doctrine_Lib::removeDirectories($directory);
} catch (Exception $e) {
throw new Exception(__METHOD__ . ':' . __LINE__ . '|' . $e->getMessage());
}
return 0;
}
开发者ID:hglattergotz,项目名称:uUtilitiesPlugin,代码行数:27,代码来源:SchemaBuilder.class.php
注:本文中的Doctrine_Lib类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论