本文整理汇总了PHP中Arr::path方法的典型用法代码示例。如果您正苦于以下问题:PHP Arr::path方法的具体用法?PHP Arr::path怎么用?PHP Arr::path使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Arr
的用法示例。
在下文中一共展示了Arr::path方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: load
public function load($group)
{
if (!count($this->_sources)) {
throw new JsonApiApplication_Exception("No configuration sources attached");
}
if (empty($group)) {
throw new JsonApiApplication_Exception("Need to specify a config group");
}
if (!is_string($group)) {
throw new JsonApiApplication_Exception("Config group must be a string");
}
if (strpos($group, ".") !== FALSE) {
list($group, $path) = explode(".", $group, 2);
}
if (isset($this->_groups[$group])) {
if (isset($path)) {
return Arr::path($this->_groups[$group], $path, NULL, ".");
}
return $this->_groups[$group];
}
$config = array();
$sources = array_reverse($this->_sources);
foreach ($sources as $source) {
if ($source instanceof JsonApiApplication_Config_Reader) {
if ($source_config = $source->load($group)) {
$config = Arr::merge($config, $source_config);
}
}
}
$this->_groups[$group] = new JsonApiApplication_Config_Group($this, $group, $config);
if (isset($path)) {
return Arr::path($config, $path, NULL, ".");
}
return $this->_groups[$group];
}
示例2: is_multi
public static function is_multi($id)
{
if (!self::$enums) {
self::init();
}
return Arr::path(self::$enums, $id . '.allow_multi');
}
示例3: content
/**
* Render view.
*
* @return string
*/
public function content()
{
ob_start();
$foursquare = $this->venue->foursquare();
if (!$foursquare) {
echo new View_Alert(__('This venue has not been linked to Foursquare yet.'), null, View_Alert::INFO);
} else {
// Homepage
echo HTML::anchor(Arr::path($foursquare, 'short_url'), HTML::image(Arr::path($foursquare, 'primarycategory.iconurl'), array('alt' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')), 'title' => HTML::chars(Arr::path($foursquare, 'primarycategory.nodename')))) . ' ' . HTML::chars(Arr::path($foursquare, 'primarycategory.nodename'))), '<br />';
// Mayor
if ($mayor = Arr::path($foursquare, 'stats.mayor.user')) {
echo __('Mayor: :mayor, :city', array(':mayor' => HTML::anchor('http://foursquare.com/user/' . Arr::get($mayor, 'id'), HTML::chars(Arr::get($mayor, 'firstname')) . ' ' . HTML::chars(Arr::get($mayor, 'lastname'))), ':city' => HTML::chars($mayor['homecity']))), '<br />';
}
// Checkins
echo __('Check-ins: :checkins', array(':checkins' => '<var>' . Arr::path($foursquare, 'stats.checkins') . '</var>')), '<br />';
// Here now
echo __('Here now: :herenow', array(':herenow' => '<var>' . Arr::path($foursquare, 'stats.herenow') . '</var>')), '<br />';
// Tips
if ($tips = Arr::path($foursquare, 'tips')) {
echo '<h5>', __('Tips (:tips)', array(':tips' => '<var>' . count($tips) . '</var>')), '</h5><dl>';
foreach (array_slice($tips, 0, 5) as $tip) {
echo '<dt>', HTML::anchor('http://foursquare.com/user/' . Arr::path($tip, 'user.id'), HTML::chars(Arr::path($tip, 'user.firstname')) . ' ' . HTML::chars(Arr::path($tip, 'user.lastname'))), ', ', HTML::chars(Arr::path($tip, 'user.homecity')), ':</dt>';
echo '<dd>', Text::auto_p(HTML::chars(Arr::path($tip, 'text'))), '</dd>';
}
echo '</dl>';
}
}
// Admin controls
if (Permission::has($this->venue, Model_Venue::PERMISSION_UPDATE)) {
echo HTML::anchor('#map', __('Link to Foursquare'), array('class' => 'action', 'id' => 'link-foursquare'));
echo $this->form();
}
return ob_get_clean();
}
示例4: before
public function before()
{
$fullBaseUrl = Url::base(true);
//was user on our site?
if (strpos($this->request->referrer(), $fullBaseUrl) === 0) {
//now check that a controller set, it wasn't the user controller, and that the session var "noReturn" is not false
$uri = parse_url($this->request->referrer(), PHP_URL_PATH);
// correct the path for url_base and index_file, in part taken from Kohana_Request::detect_uri()
// Get the path from the base URL, including the index file
$base_url = parse_url(Kohana::$base_url, PHP_URL_PATH);
if (strpos($uri, $base_url) === 0) {
// Remove the base URL from the URI
$uri = (string) substr($uri, strlen($base_url));
}
if (Kohana::$index_file and strpos($uri, Kohana::$index_file) === 0) {
// Remove the index file from the URI
$uri = (string) substr($uri, strlen(Kohana::$index_file));
}
$processedRef = Request::process_uri($uri);
$referrerController = Arr::path($processedRef, 'params.controller', false);
if ($referrerController && $referrerController != 'user' && !Session::instance()->get('noReturn', false)) {
Session::instance()->set('returnUrl', $this->request->referrer());
}
}
parent::before();
}
示例5: config
/**
* @param null|mixed $path
* @param null|mixed $default
* @param null|string $delimeter
*
* @return array|mixed
*/
public function config($path = NULL, $default = NULL, $delimeter = NULL)
{
if (NULL === $this->_config) {
$this->_config = Kohana::$config->load('geocode')->as_array();
}
return NULL === $path ? $this->_config : Arr::path($this->_config, $path, $default, $delimeter);
}
示例6: load
/**
* Load modules config
*
* @param $group
* @param $module
* @return mixed
* @throws Kohana_Exception
*/
public function load($group, $module)
{
if (empty($group) || empty($module)) {
throw new Twig_Exception("Need to specify a config group and module name");
}
if (!is_string($group) || !is_string($module)) {
throw new Twig_Exception("Config group and module name must be a string");
}
if (strpos($group, '.') !== FALSE) {
// Split the config group and path
list($group, $path) = explode('.', $group, 2);
}
if (isset($this->_config_groups[$group])) {
if (isset($path)) {
return Arr::path($this->_config_groups[$group], $path, NULL, '.');
}
return $this->_config_groups[$group];
}
$config = array();
$file = $this->_get_config_file($group, $module);
if (is_file($file)) {
$config = Arr::merge($config, Kohana::load($file));
}
$this->_config_groups[$group] = new Config_Group(Kohana::$config, $group, $config);
if (isset($path)) {
return Arr::path($config, $path, NULL, '.');
}
return $this->_config_groups[$group];
}
示例7: verify_access_token
/**
* Verify the access token.
*
* @param array an associative array of auth settings
* @return OAuthToken
* @link http://digg.com/api/docs/1.0/detail/oauth.verify
*/
public function verify_access_token()
{
// Configure the auth settings
$auth_config = array();
if ($this->is_valid_token(NULL, TRUE)) {
$token = $this->_token;
$auth_config = array('token_key' => $token->key, 'token_secret' => $token->secret);
}
$auth_config = Arr::merge($this->_auth_config, $auth_config);
// Configure the HTTP method, URL, and request parameters
$http_method = MMI_HTTP::METHOD_POST;
$url = $this->_api_url;
$parms = array('method' => 'oauth.verify');
// Verify the request token
$verified = 0;
$response = $this->_auth_request($auth_config, $http_method, $url, $parms);
if ($response instanceof MMI_Curl_Response) {
$http_status_code = $response->http_status_code();
if (intval($http_status_code) === 200) {
$data = $this->_decode_xml($response->body(), TRUE);
if (is_array($data)) {
$verified = intval(Arr::path($data, '@attributes.verified', 0));
}
}
}
unset($response);
return $verified === 1;
}
示例8: extract
/**
* Retrieves multiple paths from an array. If the path does not exist in the
* array, the default value will be added instead.
*
* // Get the values "username", "password" from $_POST
* $auth = Arr::extract($_POST, array('username', 'password'));
*
* // Get the value "level1.level2a" from $data
* $data = array('level1' => array('level2a' => 'value 1', 'level2b' => 'value 2'));
* Arr::extract($data, array('level1.level2a', 'password'));
*
* @param array $array array to extract paths from
* @param array $paths list of path
* @param mixed $default default value
* @return array
*/
public static function extract($array, array $paths, $default = NULL)
{
$found = array();
foreach ($paths as $path) {
Arr::set_path($found, $path, Arr::path($array, $path, $default));
}
return $found;
}
示例9: config
public function config($group, $type, $model_name = NULL)
{
$model_name = $model_name ? $model_name : $this->model_name;
$config = self::$_config === NULL ? self::$_config = Kohana::$config->load('huia/api') : self::$_config;
$custom = $config->get('custom_' . $group);
$regexp = Arr::path($custom, strtolower(Inflector::singular($model_name)) . '.' . $type);
return $regexp !== NULL ? $regexp : Arr::get($config->get($group), $type);
}
示例10: as_array
public function as_array()
{
$data = parent::as_array();
$data['options'] = json_decode($data['options'], true);
if (!Arr::path($data, "options.title.text", false)) {
Arr::set_path($data, "options.title.text", __($data['name']));
}
return $data;
}
示例11: action_index
/**
* Test the Mixx API.
*
* @return void
*/
public function action_index()
{
$config = MMI_API::get_config(TRUE);
$username = Arr::path($config, 'mixx.auth.username', 'memakeit');
$svc = MMI_API::factory(MMI_API::SERVICE_MIXX);
// $response = $svc->get('users/show', array('user_key' => $username));
$requests = array('profile' => array('url' => 'users/show', 'parms' => array('user_key' => $username)), 'real-life-size-bus-transformer' => array('url' => 'thingies/show', 'parms' => array('url' => 'http://www.atcrux.com/2010/03/11/real-life-size-bus-transformer/', 'comments' => 1, 'tags' => 1)));
$response = $svc->mget($requests);
$this->_set_response($response, $svc->service());
}
示例12: action_index
public function action_index()
{
$logs = ORM::factory('log')->filter();
Assets::css('logs', 'cms/media/css/controller/logs.css');
$per_page = (int) Arr::get($this->request->query(), 'per_page', 20);
$pager = Pagination::factory(array('total_items' => $logs->reset(FALSE)->count_all(), 'items_per_page' => $per_page));
$sidebar = new Sidebar(array(new Sidebar_Fields_DateRange(array('label' => __('Date range'), 'name' => 'created_on', 'range' => array(array('name' => '', 'value' => Arr::path($this->request->query(), 'created_on.0')), array('name' => '', 'value' => Arr::path($this->request->query(), 'created_on.1'))))), new Sidebar_Fields_Select(array('name' => 'level[]', 'label' => __('Log level'), 'options' => Log::levels(), 'selected' => (array) $this->request->query('level'))), new Sidebar_Fields_Input(array('name' => 'per_page', 'label' => __('Items per page'), 'value' => $per_page, 'size' => 3))));
$this->set_title(__('Logs'), FALSE);
$this->template->content = View::factory('logs/index', array('logs' => $logs->with('user')->limit($pager->items_per_page)->offset($pager->offset)->find_all(), 'pager' => $pager, 'sidebar' => $sidebar));
}
示例13: action_index
/**
* Test the GitHub API.
*
* @return void
*/
public function action_index()
{
$config = MMI_API::get_config(TRUE);
$username = Arr::path($config, 'github.auth.username', 'memakeit');
$svc = MMI_API::factory(MMI_API::SERVICE_GITHUB);
// $response = $svc->get("user/show/{$username}");
$requests = array($username => array('url' => "user/show/{$username}"), 'shadowhand' => array('url' => 'user/show/shadowhand'));
$response = $svc->mget($requests);
$this->_set_response($response, $svc->service());
}
示例14: action_index
/**
* Test the Gowalla API.
*
* @return void
*/
public function action_index()
{
$config = MMI_API::get_config(TRUE);
$username = Arr::path($config, 'gowalla.auth.username', 'memakeit');
$svc = MMI_API::factory(MMI_API::SERVICE_GOWALLA);
// $response = $svc->get("users/{$username}");
$requests = array('profile' => array('url' => "users/{$username}"), 'stamps' => array('url' => "users/{$username}/stamps"), 'top spots' => array('url' => "users/{$username}/top_spots"));
$response = $svc->mget($requests);
$this->_set_response($response, $svc->service());
}
示例15: action_index
/**
* Test the SlideShare API.
*
* @return void
*/
public function action_index()
{
$config = MMI_API::get_config(TRUE);
$username = Arr::path($config, 'slideshare.auth.username', 'memakeit');
$svc = MMI_API::factory(MMI_API::SERVICE_SLIDESHARE);
// $response = $svc->get('get_slideshows_by_user', array('username_for' => $username, 'detailed' => '1'));
$requests = array('user slideshows' => array('url' => 'get_slideshows_by_user', 'parms' => array('username_for' => $username, 'detailed' => '1')), 'user groups' => array('url' => 'get_user_groups', 'parms' => array('username_for' => $username)), 'user contacts' => array('url' => 'get_user_contacts', 'parms' => array('username_for' => $username)), 'get slideshow' => array('url' => 'get_slideshow', 'parms' => array('slideshow_url' => 'http://www.slideshare.net/vortexau/improving-php-application-performance-with-apc-presentation', 'detailed' => '1')));
$response = $svc->mget($requests);
$this->_set_response($response, $svc->service());
}