本文整理汇总了PHP中Zend\Config\Config::setReadOnly方法的典型用法代码示例。如果您正苦于以下问题:PHP Config::setReadOnly方法的具体用法?PHP Config::setReadOnly怎么用?PHP Config::setReadOnly使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Zend\Config\Config
的用法示例。
在下文中一共展示了Config::setReadOnly方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getLayoutStructure
/**
*
* @return Config
*/
public function getLayoutStructure()
{
if (null === $this->layoutStructure) {
$this->layoutStructure = new Config([], true);
$handles = $this->getHandles();
$event = new UpdateEvent();
$event->setLayoutStructure($this->layoutStructure);
$event->setHandles($handles);
$event->setArea($this->getArea());
$event->setName(UpdateEvent::EVENT_COLLECT);
$event->setTarget($this);
$results = $this->getEventManager()->triggerEventUntil(function ($result) {
return $result instanceof Config;
}, $event);
if ($results->stopped()) {
$this->layoutStructure = $results->last();
} else {
$this->fetchUpdates();
$event->setName(UpdateEvent::EVENT_COLLECT_POST);
$this->getEventManager()->triggerEvent($event);
}
$this->layoutStructure->setReadOnly();
}
return $this->layoutStructure;
}
示例2: getMergedConfig
/**
* getMergedConfig
* Build a merged config object for all loaded modules
*
* @return Zend\Config\Config
*/
public function getMergedConfig($readOnly = true)
{
if (null === $this->mergedConfig) {
$this->setMergedConfig(new Config(array(), true));
}
if (true === $readOnly) {
$this->mergedConfig->setReadOnly();
}
return $this->mergedConfig;
}
示例3: getLayoutStructure
/**
*
* @return Config
*/
public function getLayoutStructure()
{
if (null === $this->layoutStructure) {
$this->layoutStructure = new Config([], true);
$handles = $this->getHandles();
$event = new UpdateEvent();
$event->setLayoutStructure($this->layoutStructure);
$event->setHandles($handles);
$event->setArea($this->getArea());
$results = $this->getEventManager()->trigger(__FUNCTION__ . '.pre', $this, $event, function ($result) {
return $result instanceof Config;
});
if ($results->stopped()) {
$this->layoutStructure = $results->last();
} else {
$this->getEventManager()->trigger(__FUNCTION__ . '.post', $this, $event);
}
$this->layoutStructure->setReadOnly();
}
return $this->layoutStructure;
}
示例4: testSetReadOnlyAppliesToChildren
/**
* @group ZF-4728
*
*/
public function testSetReadOnlyAppliesToChildren()
{
$config = new Config($this->all, true);
$config->setReadOnly();
$this->assertTrue($config->isReadOnly());
$this->assertTrue($config->one->isReadOnly(), 'First level children are writable');
$this->assertTrue($config->one->two->isReadOnly(), 'Second level children are writable');
}
示例5: validateFields
/**
* Validate fields and their data
*
* @param Config $fields Fields
* @return Config Validated fields
* @throws Exception
*/
protected function validateFields(Config $fields) : Config
{
$valid_field_attributes = ['name', 'required', 'form', 'multivalue'];
/** @var Config $field */
foreach ($fields as $field) {
if (!$field->offsetExists('name')) {
throw new Exception("Name is mandatory attribute for a field!");
}
foreach ($field as $attribute => $value) {
if (!in_array($attribute, $valid_field_attributes)) {
throw new Exception(sprintf("Field base attribute %s is not valid!", $attribute));
}
switch ($attribute) {
case 'required':
$field->offsetSet($attribute, (int) $value);
if ($value !== 1) {
throw new Exception(sprintf("Only valid values for required is 1, value of '%s' (%s) was given.", $value, gettype($value)));
}
break;
}
// TODO check if attribute has a validator?
}
}
$fields->setReadOnly();
return $fields;
}