本文整理汇总了PHP中a::missing方法的典型用法代码示例。如果您正苦于以下问题:PHP a::missing方法的具体用法?PHP a::missing怎么用?PHP a::missing使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类a
的用法示例。
在下文中一共展示了a::missing方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: create
public function create($uid, $template, $content = array())
{
if (empty($template)) {
throw new Exception(l('pages.add.error.template'));
}
$uid = empty($uid) ? str::random(32) : $uid;
$blueprint = new Blueprint($template);
$data = array();
foreach ($blueprint->fields(null) as $key => $field) {
$data[$key] = $field->default();
}
$data = array_merge($data, $content);
// create the new page and convert it to a page model
$page = new Page($this->page, parent::create($uid, $template, $data)->dirname());
if (!$page) {
throw new Exception(l('pages.add.error.create'));
}
kirby()->trigger('panel.page.create', $page);
// subpage builder
foreach ((array) $page->blueprint()->pages()->build() as $build) {
$missing = a::missing($build, array('title', 'template', 'uid'));
if (!empty($missing)) {
continue;
}
$subpage = $page->children()->create($build['uid'], $build['template'], array('title' => $build['title']));
if (isset($build['num'])) {
$subpage->sort($build['num']);
}
}
return $page;
}
示例2: testMissing
public function testMissing()
{
$user = $this->user;
$required = array('username', 'password', 'website');
$missing = a::missing($user, $required);
$this->assertEquals(array('website'), $missing);
}
示例3: createPage
public static function createPage($uri, $title, $template, $uid)
{
$parent = empty($uri) ? site() : page($uri);
$uid = empty($uid) ? str::slug($title) : str::slug($uid);
if (empty($title)) {
throw new Exception(l('pages.add.error.title'));
}
if (empty($template)) {
throw new Exception(l('pages.add.error.template'));
}
$data = pagedata::createByBlueprint($template, array('title' => $title));
$page = $parent->children()->create($uid, $template, $data);
$blueprint = blueprint::find($page);
if (is_array($blueprint->pages()->build())) {
foreach ($blueprint->pages()->build() as $build) {
$missing = a::missing($build, array('title', 'template', 'uid'));
if (!empty($missing)) {
continue;
}
static::createPage($page->uri(), $build['title'], $build['template'], $build['uid']);
}
}
return $page;
}
示例4: dataValid
/**
* Checks if all required data is present to send the form.
*/
private function dataValid($requiredFields, $validateFields)
{
// check if all required fields are there
$this->erroneousFields = a::missing($this->data, array_keys($requiredFields));
if (!empty($this->erroneousFields)) {
$this->message = l::get('sendform-fields-required');
return false;
}
// perform validation for all fields with a given validation method
foreach ($validateFields as $field => $method) {
$value = a::get($this->data, $field);
// validate only if a method is given and the field contains data
if (!empty($method) && !empty($value) && !call('v::' . $method, $value)) {
array_push($this->erroneousFields, $field);
}
}
if (!empty($this->erroneousFields)) {
$this->message = l::get('sendform-fields-not-valid');
return false;
}
return true;
}
示例5: load
static function load($username)
{
// check for an existing user account file
$file = c::get('root.site') . '/' . c::get('panel.folder') . '/accounts/' . $username . '.php';
if (!file_exists($file)) {
return false;
}
// load the account credentials
content::start();
require $file;
$account = content::end(true);
$account = spyc_load($account);
if (!is_array($account)) {
return false;
}
// check for required fields
$missing = a::missing($account, array('username', 'password'));
if (!empty($missing)) {
return false;
}
return $account;
}
示例6: validate
/**
* Checks if all required keys are in the 'raw' event array. Throws an
* exception if one is missing.
*
* @param array $event a 'raw' event array containing all fields
*/
private static function validate($event)
{
$missingKeys = a::missing($event, self::$requiredKeys);
if ($missingKeys) {
$message = "Event creation failed because of the following missing " . "required fields:\n" . a::show($missingKeys, false);
throw new Exception($message, 1);
}
}