本文整理汇总了PHP中Doctrine_Lib类的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Lib类的具体用法?PHP Doctrine_Lib怎么用?PHP Doctrine_Lib使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了Doctrine_Lib类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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);
}
}
示例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');
}
}
示例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'))));
}
示例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);
}
示例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;
}
示例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();
}
}
示例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']);
}
示例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;
}
}
示例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();
}
示例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));
}
}
示例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();
}
}
示例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');
}
示例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']);
}
示例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);
}
}
示例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);
}