本文整理匯總了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;
}