本文整理匯總了PHP中Doctrine_Lib::arrayDeepMerge方法的典型用法代碼示例。如果您正苦於以下問題:PHP Doctrine_Lib::arrayDeepMerge方法的具體用法?PHP Doctrine_Lib::arrayDeepMerge怎麽用?PHP Doctrine_Lib::arrayDeepMerge使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在類Doctrine_Lib
的用法示例。
在下文中一共展示了Doctrine_Lib::arrayDeepMerge方法的15個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的PHP代碼示例。
示例1: __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);
}
示例2: 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;
}
示例3: __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();
}
}
示例4: __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);
}
}
示例5: __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');
}
}
示例6: 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();
}
示例7: 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;
}
}
示例8: __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));
}
}
示例9: __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();
}
}
示例10: __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']);
}
示例11: __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);
}
示例12: __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;
}
}
}
示例13: 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;
}
示例14: joinForTableProxy
public function joinForTableProxy(Doctrine_Query $q, array $options = array())
{
$options = Doctrine_Lib::arrayDeepMerge($this->_options, $options);
$q->getRootAlias();
// fix for initialize root
if (empty($options['parentTable'])) {
$parentTable = $q->getRoot();
$parentTableAlias = $q->getRootAlias();
} else {
$parentTable = Doctrine::getTable($options['parentTable']);
$parentTableAlias = empty($options['parentTableAlias']) ? $q->getSqlTableAlias(sfInflector::tableize($options['parentTable'])) : $options['parentTableAlias'];
}
if (!empty($options['componentAlias'])) {
$componentAlias = $options['componentAlias'];
} elseif ($parentTable->hasRelation($this->_table->getComponentName())) {
$componentAlias = $this->_table->getComponentName();
} else {
$componentName = $this->_table->getComponentName();
$relations = $parentTable->getRelations();
foreach ($relations as $relation) {
if ($relation['class'] == $componentName) {
$componentAlias = $relation['alias'];
break;
}
}
}
$tableAlias = empty($options['tableAlias']) ? $this->_table->getAlias() : $options['tableAlias'];
$q->addSqlTableAlias($tableAlias, sfInflector::tableize($this->_table->getComponentName()));
$q->leftJoin($parentTableAlias . '.' . $componentAlias . ' ' . $tableAlias);
if ($options['withI18n'] == true && $this->_table->hasTemplate('Doctrine_Template_I18nMod')) {
$cultures = empty($options['cultures']) ? sfContext::getInstance()->getUser()->getCulture() : $options['cultures'];
$chunkWith = implode(' AND ', array_fill(0, count($cultures), ' ' . $tableAlias . '_trans.lang = ? '));
$q->leftJoin($tableAlias . '.Translation ' . $tableAlias . '_trans WITH ' . $chunkWith, $cultures);
}
return $q;
}
示例15: _processInheritance
/**
* _processInheritance
*
* Perform some processing on inheritance.
* Sets the default type and sets some default values for certain types
*
* @param string $array
* @return void
*/
protected function _processInheritance($array)
{
// Apply default inheritance configuration
foreach ($array as $className => $definition) {
if (!empty($array[$className]['inheritance'])) {
$this->_validateSchemaElement('inheritance', array_keys($definition['inheritance']), $className . '->inheritance');
// Default inheritance to concrete inheritance
if (!isset($array[$className]['inheritance']['type'])) {
$array[$className]['inheritance']['type'] = 'concrete';
}
// Some magic for setting up the keyField and keyValue column aggregation options
// Adds keyField to the parent class automatically
if ($array[$className]['inheritance']['type'] == 'column_aggregation') {
// Set the keyField to 'type' by default
if (!isset($array[$className]['inheritance']['keyField'])) {
$array[$className]['inheritance']['keyField'] = 'type';
}
// Set the keyValue to the name of the child class if it does not exist
if (!isset($array[$className]['inheritance']['keyValue'])) {
$array[$className]['inheritance']['keyValue'] = $className;
}
$parent = $this->_findBaseSuperClass($array, $definition['className']);
// Add the keyType column to the parent if a definition does not already exist
if (!isset($array[$parent]['columns'][$array[$className]['inheritance']['keyField']])) {
$array[$parent]['columns'][$array[$className]['inheritance']['keyField']] = array('name' => $array[$className]['inheritance']['keyField'], 'type' => 'string', 'length' => 255);
}
}
}
}
// Array of the array keys to move to the parent, and the value to default the child definition to
// after moving it. Will also populate the subclasses array for the inheritance parent
$moves = array('columns' => array(), 'indexes' => array(), 'attributes' => array(), 'options' => array(), 'checks' => array());
foreach ($array as $className => $definition) {
// Move any definitions on the schema to the parent
if (isset($definition['inheritance']['extends']) && isset($definition['inheritance']['type']) && ($definition['inheritance']['type'] == 'simple' || $definition['inheritance']['type'] == 'column_aggregation')) {
$parent = $this->_findBaseSuperClass($array, $definition['className']);
foreach ($moves as $move => $resetValue) {
if (isset($array[$parent][$move]) && isset($definition[$move])) {
$array[$parent][$move] = Doctrine_Lib::arrayDeepMerge($array[$parent][$move], $definition[$move]);
$array[$definition['className']][$move] = $resetValue;
}
}
// Populate the parents subclasses
if ($definition['inheritance']['type'] == 'column_aggregation') {
// Fix for 2015: loop through superclasses' inheritance to the base-superclass to
// make sure we collect all keyFields needed (and not only the first)
$inheritanceFields = array($definition['inheritance']['keyField'] => $definition['inheritance']['keyValue']);
$superClass = $definition['inheritance']['extends'];
$multiInheritanceDef = $array[$superClass];
while (count($multiInheritanceDef['inheritance']) > 0 && array_key_exists('extends', $multiInheritanceDef['inheritance']) && $multiInheritanceDef['inheritance']['type'] == 'column_aggregation') {
$superClass = $multiInheritanceDef['inheritance']['extends'];
// keep original keyField with it's keyValue
if (!isset($inheritanceFields[$multiInheritanceDef['inheritance']['keyField']])) {
$inheritanceFields[$multiInheritanceDef['inheritance']['keyField']] = $multiInheritanceDef['inheritance']['keyValue'];
}
$multiInheritanceDef = $array[$superClass];
}
$array[$parent]['inheritance']['subclasses'][$definition['className']] = $inheritanceFields;
}
}
}
return $array;
}