本文整理汇总了PHP中Ak::first方法的典型用法代码示例。如果您正苦于以下问题:PHP Ak::first方法的具体用法?PHP Ak::first怎么用?PHP Ak::first使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Ak
的用法示例。
在下文中一共展示了Ak::first方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: hasCollisions
public function hasCollisions()
{
$this->collisions = array();
$this->namespace = AkInflector::underscore(Ak::first(explode(':', $this->task_name . ':')));
$this->task_name = AkInflector::underscore(Ak::last(explode(':', ':' . $this->task_name)));
$this->destination_path = AK_TASKS_DIR . DS . $this->namespace;
if (file_exists($this->destination_path . DS . $this->task_name . '.task.php')) {
$this->collisions[] = Ak::t('%path already exists', array('%path' => $this->destination_path . DS . $this->task_name . '.task.php'));
}
return count($this->collisions) > 0;
}
示例2: getResourcePathNameFor
static function getResourcePathNameFor($name, $default = null)
{
$result = Ak::first(Ak::pick($name, AkConfig::getOption('resources_path_names', array('add' => 'add', 'edit' => 'edit'))));
return empty($result) ? $default : $result;
}
示例3: ak_get_application_included_files
function ak_get_application_included_files($source_for = '')
{
$app_files = array();
foreach (get_included_files() as $k => $file) {
if (strstr($file, AK_FRAMEWORK_DIR)) {
continue;
}
$short_path = str_replace(AK_BASE_DIR, '', $file);
if (strstr($file, AK_MODELS_DIR)) {
$app_files['Models'][$k]['path'] = $short_path;
if ($file == $source_for) {
$app_files['Models'][$k]['original_path'] = $file;
}
} elseif (strstr($file, AK_COMPILED_VIEWS_DIR)) {
$path = Ak::first(explode('.tpl.', str_replace(array(AK_COMPILED_VIEWS_DIR, '/compiled'), '', $file))) . '.tpl';
if (!in_array($path, array('/app/views/exception.tpl', '/app/views/_trace.tpl'))) {
$app_files['Views'][$k]['path'] = $path;
if ($file == $source_for) {
$app_files['Views'][$k]['original_path'] = $file;
}
}
} elseif (strstr($file, AK_CONTROLLERS_DIR)) {
$app_files['Controllers'][$k]['path'] = $short_path;
if ($file == $source_for) {
$app_files['Controllers'][$k]['original_path'] = $file;
}
} elseif (strstr($file, AK_HELPERS_DIR)) {
$app_files['Helpers'][$k]['path'] = $short_path;
if ($file == $source_for) {
$app_files['Helpers'][$k]['original_path'] = $file;
}
}
}
return $app_files;
}
示例4: getOffset
public function getOffset()
{
return Ak::first($this->paginator->getOffsetByPageId($this->getCurrent())) - 1;
}
示例5: _getLocaleForRequest
protected function _getLocaleForRequest(&$Request)
{
if (isset($Request->lang)) {
$lang = $Request->lang;
} else {
$lang = $this->getNavigationLanguage();
}
if ($url_locale = $this->getLangFromUrl($Request)) {
$lang = $this->getLocaleFromAlias($url_locale);
}
if (!$this->_canUseLocaleOnCurrentRequest($lang, $Request)) {
$lang = Ak::first($this->getPublicLocales());
} elseif (empty($lang)) {
$lang = Ak::first($this->getPublicLocales());
}
// This way we store on get_url_locale and on lang the value of $lang on
// a static variable for accessing it application wide
empty($url_locale) ? null : Ak::get_url_locale($url_locale);
Ak::lang($lang);
return $lang;
}
示例6: test_attachment_with_text_type
function test_attachment_with_text_type()
{
$TestMailer =& new TestMailer();
$Mail =& $TestMailer->receive(file_get_contents(AK_TEST_DIR."/fixtures/data/action_mailer/raw_email13"));
$this->assertTrue($Mail->hasAttachments());
$this->assertEqual(1, Ak::size($Mail->attachments));
$Attachment = Ak::first($Mail->attachments);
$this->assertEqual("hello.rb", $Attachment->original_filename);
}
示例7: test_attachment_with_text_type
public function test_attachment_with_text_type()
{
$TestMailer = new TestMailer();
$Mail = $TestMailer->receive(file_get_contents(AkConfig::getDir('fixtures') . DS . "raw_email13"));
$this->assertTrue($Mail->hasAttachments());
$this->assertEqual(1, Ak::size($Mail->attachments));
$Attachment = Ak::first($Mail->attachments);
$this->assertEqual("hello.rb", $Attachment->original_filename);
}
示例8: get
/**
* Get a models a model instance. Including and instantiating the model for us.
*
* This kinds mimics the ideal (new Model())->find() which does not exist on PHP yet.
*
* On Akelos we can do Ak::get('Model')->find();
*/
static function get($model_name, $attributes = array())
{
$model_name = Ak::first(Ak::import($model_name));
if (!empty($model_name)) {
return new $model_name($attributes);
}
}
示例9: getAccountSubdomain
public function getAccountSubdomain()
{
return Ak::first($this->Request->getSubdomains());
}
示例10: _getGeneratorsInsidePath
private function _getGeneratorsInsidePath($path)
{
$generators = array();
if (is_dir($path)) {
foreach (AkFileSystem::dir($path, array('files' => false, 'dirs' => true)) as $folder) {
$generator = Ak::first(array_keys($folder));
if (strstr($generator, '.php') || is_file($path . DS . $generator)) {
continue;
}
$generators[$path . DS . $generator . DS . $generator . '_generator.php'] = $generator;
}
}
return $generators;
}
示例11: getPluginHelperNames
public function getPluginHelperNames()
{
$handler = $this->_Handler;
$handler->plugin_helpers = !isset($handler->plugin_helpers) ? 'all' : $handler->plugin_helpers;
$helper_names = AkHelperLoader::addPluginHelper(false);
// Trick for getting helper names set by AkPlugin::addHelper
if (empty($helper_names)) {
return array();
} elseif ($handler->plugin_helpers == 'all') {
return $helper_names;
} else {
$selected_helper_names = array();
foreach (Ak::toArray($handler->plugin_helpers) as $helper_name) {
$helper_name = AkInflector::camelize($helper_name);
if ($path = Ak::first(array_keys($helper_names, AkInflector::camelize($helper_name)))) {
$selected_helper_names[$path] = $helper_names[$path];
}
}
return $selected_helper_names;
}
}