本文整理汇总了PHP中array_only函数的典型用法代码示例。如果您正苦于以下问题:PHP array_only函数的具体用法?PHP array_only怎么用?PHP array_only使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了array_only函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: getConfig
/**
* Get the configuration data.
*
* @param string[] $config
*
* @throws \InvalidArgumentException
*
* @return string
*/
protected function getConfig(array $config)
{
if (!array_key_exists('token', $config)) {
throw new \InvalidArgumentException('The GitLab client requires configuration.');
}
return array_only($config, ['token', 'base_url', 'method', 'sudo']);
}
示例2: getConfig
/**
* Get the configuration data.
*
* @param string[] $config
*
* @throws \InvalidArgumentException
*
* @return array
*/
protected function getConfig(array $config)
{
if (!array_key_exists('client_id', $config)) {
throw new InvalidArgumentException('Missing configuration key [client_id].');
}
return array_only($config, ['client_id', 'client_secret', 'callback_url']);
}
示例3: getConfig
/**
* Get the configuration.
*
* @param string[] $config
*
* @throws \InvalidArgumentException
*
* @return string[]
*/
protected function getConfig(array $config)
{
if (!array_key_exists('token', $config) || !array_key_exists('email', $config)) {
throw new \InvalidArgumentException('The cloudflare client requires configuration.');
}
return array_only($config, ['token', 'email']);
}
示例4: transform
/**
* Transform row data by columns definition.
*
* @param array $row
* @param mixed $columns
* @param string $type
* @return array
*/
public function transform(array $row, $columns, $type = 'printable')
{
if ($columns instanceof Collection) {
return $this->buildColumnByCollection($row, $columns, $type);
}
return array_only($row, $columns);
}
示例5: testStore
public function testStore()
{
$project = Factory::build('Project', ['name' => 'Foo']);
$input = array_only($project->getAttributes(), $project->getFillable());
$this->action('POST', 'Admin\\ProjectsController@store', $input);
$this->assertRedirectedToRoute('admin.projects.show', 'foo');
}
示例6: __construct
/**
* Creates a new Lavary\Menu\MenuItem instance.
*
* @param string $title
* @param string $url
* @param array $attributes
* @param int $parent
* @param \Lavary\Menu\Menu $builder
* @return void
*/
public function __construct($builder, $id, $title, $options)
{
$this->builder = $builder;
$this->id = $id;
$this->title = $title;
$this->nickname = camel_case($title);
$this->attributes = $this->builder->extractAttributes($options);
$this->parent = is_array($options) && isset($options['parent']) ? $options['parent'] : null;
// Storing path options with each link instance.
if (!is_array($options)) {
$path = array('url' => $options);
} elseif (isset($options['raw']) && $options['raw'] == true) {
$path = null;
} else {
$path = array_only($options, array('url', 'route', 'action', 'secure'));
}
if (!is_null($path)) {
$path['prefix'] = $this->builder->getLastGroupPrefix();
}
$this->link = $path ? new Link($path) : null;
// Activate the item if items's url matches the request uri
if (true === $this->builder->conf('auto_activate')) {
$this->checkActivationStatus();
}
}
示例7: getConfig
/**
* Get the configuration data.
*
* @param string[] $config
*
* @throws \InvalidArgumentException
*
* @return string[]
*/
protected function getConfig(array $config)
{
if (!array_key_exists('app_key', $config) || !array_key_exists('app_secret', $config)) {
throw new \InvalidArgumentException('The top client requires api keys.');
}
return array_only($config, ['app_key', 'app_secret', 'format']);
}
示例8: verifyAndCreate
public function verifyAndCreate($data)
{
$compcat = $this->compcat->verifyAndCreate(array_only($data, ['supno', 'catname']));
$attr = ['code' => 'new', 'descriptor' => $data['comp'], 'compcatid' => $compcat->id, 'cost' => $data['ucost'], 'uom' => $data['unit']];
//return $this->firstOrNew($attr, ['descriptor']);
return $this->findOrNew($attr, ['descriptor']);
}
示例9: register
public static function register(array $input) : User
{
$defaults = ['role' => UserRole::MEMBER(), 'status' => UserStatus::ACTIVE()];
$user = static::create($defaults + array_only($input, ['first_name', 'last_name', 'address', 'postal', 'city', 'country', 'telephone', 'email', 'password']));
event(new UserRegistered($user));
return $user;
}
示例10: getConfig
/**
* Get the configuration.
*
* @param string[] $config
*
* @return string[]
*/
protected function getConfig(array $config)
{
if (!array_key_exists('container', $config)) {
throw new InvalidArgumentException('The azure connector requires container configuration.');
}
return array_only($config, ['container']);
}
示例11: compose
/**
* Bind data to the view.
*
* @param View $view
*
* @return void
*/
public function compose(View $view)
{
$data = $view->getData();
if (Auth::check()) {
$notifications = Auth::user()->notifications()->with('user')->orderBy('created_at', 'desc')->take(15)->get();
$view->with('notifications', $notifications);
$unreadCount = Auth::user()->notifications()->wherePivot('read', false)->count();
$view->with('newNotificationsCount', $unreadCount);
}
// Get object from which we can extract name to use as page title
$currentGroup = head(array_only($data, ['group', 'folder', 'fakeGroup']));
$view->with('currentGroup', $currentGroup);
if (isset($currentGroup) && isset($currentGroup->name)) {
$pageTitle = $currentGroup->name;
// Homepage title shall always be Strimoid.pl
if ($currentGroup->urlname == 'all' && !Setting::get('homepage_subscribed', false)) {
$pageTitle = 'Strimoid';
}
if ($currentGroup->urlname == 'subscribed' && Setting::get('homepage_subscribed', false)) {
$pageTitle = 'Strimoid';
}
} else {
$pageTitle = 'Strimoid';
}
$view->with('pageTitle', $pageTitle);
// Needed by top bar with groups
$popularGroups = Cache::remember('popularGroups', 60, function () {
return Group::orderBy('subscribers_count', 'desc', true)->take(30)->get(['id', 'name', 'urlname']);
});
$view->with('popularGroups', $popularGroups);
}
示例12: only
/**
* Get a subset of the items from the input data.
*
* @param array $keys
*
* @return array
*/
public function only($keys)
{
$keys = is_array($keys) ? $keys : func_get_args();
$results = $this->input();
$results = is_array($results) ? $results : array();
return array_only($results, $keys) + array_fill_keys($keys, null);
}
示例13: getConfig
/**
* Get the configuration data.
*
* @param string[] $config
*
* @throws \InvalidArgumentException
*
* @return array
*/
protected function getConfig(array $config)
{
if (!array_key_exists('consumer_key', $config)) {
throw new \InvalidArgumentException('The Twitter API client requires configuration.');
}
return array_only($config, ['consumer_key', 'consumer_secret', 'access_token', 'access_token_secret']);
}
示例14: testStore
public function testStore()
{
$user = Factory::build('User');
$input = array_only($user->getAttributes(), $user->getFillable());
$this->action('POST', 'Admin\\UsersController@store', $input);
$this->assertRedirectedToRoute('admin.users.show', User::first()->id);
}
示例15: setMetaDataOnCollection
private function setMetaDataOnCollection()
{
$this->meta = [];
if (isset($this->originalParsedData['ast'])) {
$this->meta = array_only($this->originalParsedData['ast'], ['metadata', 'name', 'description']);
}
}