本文整理汇总了PHP中Cake\Core\Configure::readOrFail方法的典型用法代码示例。如果您正苦于以下问题:PHP Configure::readOrFail方法的具体用法?PHP Configure::readOrFail怎么用?PHP Configure::readOrFail使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Cake\Core\Configure
的用法示例。
在下文中一共展示了Configure::readOrFail方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: find
/**
* Find path
*
* Most files will require the $module parameter to
* make search more specific. The only files that
* are currently module-independent are list CSVs.
*
* @param string $module Module to look for files in
* @param string $path Path to look for
* @return null|string|array Null for not found, string for single path, array for multiple paths
*/
public function find($module = null, $path = null)
{
if ($this->requireModule) {
if (empty($module)) {
throw new \InvalidArgumentException("Module is not specified");
}
if (!is_string($module)) {
throw new \InvalidArgumentException("Module name is not a string");
}
}
if (empty($path)) {
$path = $this->fileName;
}
if (!is_string($path)) {
throw new \InvalidArgumentException("Path is not a string");
}
if (empty($this->pathConfigKey)) {
throw new \InvalidArgumentException("pathConfigKey is empty");
}
$result = Configure::readOrFail($this->pathConfigKey);
if ($this->requireModule) {
$result .= $module . DIRECTORY_SEPARATOR;
}
$result .= $path;
$this->validatePath($result);
return $result;
}
示例2: beforeFilter
/**
* Called before the controller action. You can use this method to configure and customize components
* or perform logic that needs to happen before each controller action.
*
* @param \Cake\Event\Event $event An Event instance
* @return void
* @link http://book.cakephp.org/3.0/en/controllers.html#request-life-cycle-callbacks
*/
public function beforeFilter(Event $event)
{
$this->_controllerInstance = $event->subject();
$this->_setTableInstance($this->_controllerInstance->request->params);
// skip passing table fields if action is not supported by the plugin
if (in_array($this->request->action, Configure::readOrFail('CsvMigrations.actions'))) {
$this->_setTableFields();
}
}
示例3: _getListFieldOptions
/**
* Method that retrieves list field options.
* @param string $listName list name
* @return array
*/
protected function _getListFieldOptions($listName)
{
$result = [];
$path = Configure::readOrFail('CsvListsOptions.path') . $listName . '.csv';
$listData = $this->_getCsvData($path);
if (!empty($listData)) {
$result = $this->_prepareListOptions($listData);
}
return $result;
}
示例4: testReadOrFailThrowingException
/**
* testReadOrFail method
*
* @expectedException RuntimeException
* @expectedExceptionMessage Expected configuration key "This.Key.Does.Not.exist" not found
* @return void
*/
public function testReadOrFailThrowingException()
{
Configure::readOrFail('This.Key.Does.Not.exist');
}
示例5: _getTableFields
/**
* Method that retrieves table fields defined
* in the csv file, based on specified action
* @param object $table Table object
* @param string $action action name
* @return array table fields
*/
protected function _getTableFields($table, $action = '')
{
$tableName = $table->table();
if ('' === trim($action)) {
$action = static::ASSOC_FIELDS_ACTION;
}
$path = Configure::readOrFail('CsvViews.path');
$path .= Inflector::camelize($tableName) . DS . $action . '.csv';
$result = $this->_getFieldsFromCsv($path, $action);
$result = array_map(function ($v) {
return $v[0];
}, $result);
return $result;
}
示例6: _csvData
/**
* Get all modules data.
*
* @return array Modules, fields and fields types.
*/
protected function _csvData()
{
$result = [];
$path = Configure::readOrFail('CsvMigrations.migrations.path');
$csvFiles = $this->_getCsvFiles($path);
/*
covers case where CsvMigration configuration files reside in a plugin.
*/
$plugin = $this->_getPluginNameFromPath($path);
if (is_null($plugin)) {
/*
covers case where CsvMigration model and controller reside in
a plugin (even if configuration files reside in the APP level).
*/
$plugin = $this->_getPluginNameFromRegistryAlias();
}
$parser = new MigrationParser();
foreach ($csvFiles as $csvModule => $paths) {
if (!is_null($plugin)) {
$csvModule = $plugin . '.' . $csvModule;
}
foreach ($paths as $path) {
$result[$csvModule] = $parser->wrapFromPath($path);
}
}
return $result;
}
示例7: readOrFail
/**
* Used to get information stored in Configure. It's not
* possible to store `null` values in Configure.
*
* Acts as a wrapper around Configure::read() and Configure::check().
* The configure key/value pair fetched via this method is expected to exist.
* In case it does not an exception will be thrown.
*
* Usage:
* ```
* Configure::readOrFail('Name'); will return all values for Name
* Configure::readOrFail('Name.key'); will return only the value of Configure::Name[key]
* ```
*
* @param string $name Variable to obtain. Use '.' to access array elements.
* @return mixed Value stored in configure.
* @throws \RuntimeException if the requested configuration is not set.
*/
public function readOrFail($name)
{
return Configure::readOrFail($name);
}