本文整理汇总了PHP中F::Apply方法的典型用法代码示例。如果您正苦于以下问题:PHP F::Apply方法的具体用法?PHP F::Apply怎么用?PHP F::Apply使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类F
的用法示例。
在下文中一共展示了F::Apply方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: setFn
} else {
$Call = F::Hook('onTestNotFound', $Call);
}
return $Call;
});
setFn('Do', function ($Call) {
$Paths = F::getPaths();
$Options = [];
if (isset($Call['Test']['Name'])) {
F::Log('Test *' . $Call['Test']['Name'] . '* selected', LOG_INFO);
$VCall = F::Apply(null, 'Run', ['Test' => $Call['Test']['Name']], $Call);
$Call['Test']['Report'] = F::Merge($Call['Test']['Report'], $VCall['Test']['Report']);
} else {
F::Log('Running all tests!', LOG_INFO);
foreach ($Paths as $Path) {
if (is_dir($Path . '/Tests')) {
$Directory = new RecursiveDirectoryIterator($Path . '/Tests');
$Iterator = new RecursiveIteratorIterator($Directory);
$Regex = new RegexIterator($Iterator, '@Tests/(.+).json$@', RecursiveRegexIterator::GET_MATCH);
$Options = array_merge($Options, iterator_to_array($Regex));
}
}
sort($Options);
foreach ($Options as $Option) {
$VCall = F::Apply(null, 'Run', $Call, ['Test' => ['Name' => $Option[1]]]);
$Call['Test']['Report'] = F::Merge($Call['Test']['Report'], $VCall['Test']['Report']);
}
}
$Call['Output']['Content'][] = ['Type' => 'Table', 'Value' => $Call['Test']['Report']];
return $Call;
});
示例2: count
} else {
$Table[] = ['<l>' . $Call['Entity'] . '.Entity:' . $Name . '</l>', $OldValue, $NewValue];
}
}
$Call['Output']['Content'][] = ['Type' => 'Table', 'Value' => $Table];
}
$Call['Output']['Content'][] = ['Type' => 'Block', 'Class' => 'alert alert-success', 'Value' => count($New) . ' object touched'];
}
$Call = F::Hook('afterTouch', $Call);
return $Call;
});
setFn('All', function ($Call) {
$Call = F::Apply('Entity', 'Load', $Call);
$Total = F::Run('Entity', 'Count', $Call);
$Amount = ceil($Total / $Call['All']['Limit']);
set_time_limit(10 * $Total);
$Call = F::Apply('Code.Progress', 'Start', $Call);
$Call['Progress']['Max'] = $Amount;
for ($i = 0; $i < $Amount; $i++) {
F::Run('Entity', 'Update', ['Entity' => $Call['Entity'], 'Where' => $Call['Where'], 'Data' => [], 'One' => false, 'Limit' => ['From' => $i * $Call['All']['Limit'], 'To' => ($i + 1) * $Call['All']['Limit']]]);
$Call['Progress']['Now']++;
$Call = F::Apply('Code.Progress', 'Log', $Call);
F::Log('Touch Iteration № ' . ($i + 1) / $Amount, LOG_NOTICE);
}
$Call = F::Apply('Code.Progress', 'Finish', $Call);
$Call['Output']['Content'][] = $Total . ' elements processed';
return $Call;
});
setFn('Test', function ($Call) {
F::Run(null, "All", $Call, ['Entity' => 'User', 'Where' => ['ID' => ['$gt' => 3]], 'Live Fields' => ['VKontakte.DOB']]);
});
示例3: foreach
foreach ($Locations as $Location) {
if (!isset($Call['Location']['Slug']) or null === $Call['Location']['Slug']) {
$Location['URL'] = '/' . $Location['Slug'];
} else {
if (preg_match('@^/' . $Call['Location']['Slug'] . '@Ssuu', $Call['HTTP']['URL'])) {
$Location['URL'] = str_replace($Call['Location']['Slug'], $Location['Slug'], $Call['HTTP']['URL']);
} else {
$Location['URL'] = '/' . $Location['Slug'];
}
}
$Location['URL'] = $Call['HTTP']['Proto'] . $Call['HTTP']['Host'] . $Location['URL'];
if (isset($Call['Location']['ID']) && $Location['ID'] == $Call['Location']['ID']) {
$Call['Output']['Content'][] = '<option selected value="' . $Location['Slug'] . '"><a href="' . $Location['Slug'] . '">' . $Location['Title'] . '</a></option>';
} else {
$Call['Output']['Content'][] = '<option value="' . $Location['Slug'] . '"><a href="' . $Location['Slug'] . '">' . $Location['Title'] . '</a></option>';
}
}
}
return $Call;
});
setFn('Select', function ($Call) {
if ($Call['Location'] != $Call['Session']['Location']) {
F::Run('Session', 'Write', $Call, ['Session Data' => ['Location' => $Call['Location']]]);
}
if (isset($_SERVER['HTTP_REFERER'])) {
$Call = F::Apply('System.Interface.HTTP', 'Redirect', $Call, ['Location' => $_SERVER['HTTP_REFERER']]);
} else {
$Call = F::Apply('System.Interface.HTTP', 'Redirect', $Call, ['Location' => '/']);
}
return $Call;
});
示例4: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
require Root . '/vendor/autoload.php';
setFn('Open', function ($Call) {
$Call['Link'] = new Airbrake\Client(new Airbrake\Configuration($Call['Airbrake']['API Key'], $Call['Airbrake']['Options']));
return $Call;
});
setFn('Write', function ($Call) {
$Call = F::Apply(null, 'Open', $Call);
foreach ($Call['Data'] as $Row) {
$Call['Link']->notifyOnError($Row[3] . ':' . $Row[2]);
}
return true;
});
示例5: setFn
*/
setFn('Write', function ($Call) {
// Грузим модель связанной сущности
$Call = F::Apply('Entity', 'Load', $Call, ['Entity' => $Call['Name']]);
// Приводим значение к типу данных ID связанной сущности
// Если ID цифровое, то и наш ключ должен быть цифровой
foreach ($Call['Value'] as &$Value) {
$Value = F::Run('Data.Type.' . $Call['Nodes']['ID']['Type'], 'Write', ['Value' => $Value]);
// Подгружаем связанную сущность
$Element = F::Run('Entity', 'Read', ['One' => true, 'Entity' => $Call['Name'], 'Where' => $Value]);
// Если такой сущности нет
if (empty($Element)) {
// Смиряемся
$Value = null;
} else {
// Трогаем связанную сущность
F::Run('Entity', 'Touch', ['One' => true, 'Entity' => $Call['Name'], 'Where' => $Call['Value']]);
}
}
return $Call['Value'];
});
setFn(['Read', 'Where'], function ($Call) {
$Call = F::Apply('Entity', 'Load', $Call, ['Entity' => $Call['Name']]);
foreach ($Call['Value'] as &$Value) {
$Value = F::Run('Data.Type.' . $Call['Nodes']['ID']['Type'], 'Write', ['Value' => $Value]);
}
return $Call['Value'];
});
setFn('Populate', function ($Call) {
return null;
});
示例6: floor
} else {
$Value = null;
}
$Data = F::Dot($Data, $Key, $Value);
}
$Value = F::Dot($Data, $Key);
if (null !== $Value) {
$Keys++;
}
if (count($Value) == 1) {
$Data = F::Dot($Data, $Key, $Value[0]);
}
$Call['Data'] = $Data;
}
$Data['Percent'] = floor($Keys / count($Call['Nodes']) * 100);
$Call = F::Apply('Parser.' . $Call['Schema'], 'Do', $Call);
phpQuery::unloadDocuments();
}
} else {
F::Log('Parser Nodes *not defined*', LOG_ERR);
}
return $Call;
});
setFn('Discovery', function ($Call) {
foreach ($Call['Parser']['Discovery'] as $Rule) {
if (preg_match($Rule['Match'], $Call['URL'])) {
return $Rule['Schema'];
}
}
return null;
});
示例7: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Run', function ($Call) {
if (isset($Call['Hooks'])) {
if ($Hooks = F::Dot($Call, 'Hooks.' . $Call['On'])) {
foreach ($Hooks as $Name => $Hook) {
$Call = F::Apply($Hook['Service'], $Hook['Method'], $Call, isset($Hook['Call']) ? $Hook['Call'] : array());
}
}
}
return $Call;
});
示例8: setFn
$Call['Data'] = F::Run('Entity', 'Read', $Call, ['One' => true, 'Limit' => ['From' => 0, 'To' => 1]]);
$Call = F::Hook('afterShowBefore', $Call);
return $Call;
});
setFn('Do', function ($Call) {
$Call = F::Hook('beforeShow', $Call);
$Call = F::Hook('beforeShowDo', $Call);
/*foreach ($Call['Data'] as $Node => $Value)
{
if (isset($Call['Nodes'][$Node]['Widgets']))
;
else
unset ($Call['Data'][$Node]);
}*/
if (isset($Call['Data']['Redirect']) && !empty($Call['Data']['Redirect'])) {
$Call = F::Apply('System.Interface.HTTP', 'Redirect', $Call, ['Redirect' => $Call['Data']['Redirect']]);
} else {
$Call['Layouts'][] = ['Scope' => $Call['Entity'], 'ID' => 'Show', 'Context' => $Call['Context']];
$Call['Scope'] = isset($Call['Scope']) ? $Call['Entity'] . '/' . $Call['Scope'] : $Call['Entity'];
if (empty($Call['Data'])) {
$Call = F::Hook('onShowNotFound', $Call);
} else {
$Call['Output']['Content'][] = array('Type' => 'Template', 'Scope' => $Call['Scope'], 'ID' => 'Show/' . (isset($Call['Template']) ? $Call['Template'] : 'Full'), 'Data' => $Call['Data']);
$Call = F::Hook('afterShow', $Call);
}
}
/* if (isset($Call['Data']['Modified']))
$Call['HTTP']['Headers']['Last-Modified:'] = date(DATE_RFC2822, $Call['Data']['Modified']);
else
$Call['HTTP']['Headers']['Last-Modified:'] = date(DATE_RFC2822, $Call['Data']['Created']);*/
F::Log($Call['Data'], LOG_DEBUG);
示例9: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Detect', function ($Call) {
$Call = F::Hook('beforeLocaleDetect', $Call);
if (isset($Call['Locale'])) {
F::Log('Locale selected: *' . $Call['Locale'] . '*', LOG_INFO);
} else {
$Call['Locale'] = $Call['Default']['Locale'];
if (F::Dot($Call, 'Locales.Detect.Accept-language')) {
$Call = F::Apply(null, 'Check Accept-language', $Call);
}
}
setlocale(LC_ALL, $Call['Locales']['PHP'][$Call['Locale']]);
$Call = F::Hook('afterLocaleDetect', $Call);
return $Call;
});
setFn('Check Accept-language', function ($Call) {
if (isset($_SERVER['HTTP_ACCEPT_LANGUAGE'])) {
preg_match_all('/([a-z]{1,8}(-[a-z]{1,8})?)\\s*(;\\s*q\\s*=\\s*(1|0\\.[0-9]+))?/i', $_SERVER['HTTP_ACCEPT_LANGUAGE'], $Parsed);
$Locales = array_combine($Parsed[1], $Parsed[4]);
foreach ($Locales as $Locale => $Q) {
if ($Q === '') {
$Locales[$Locale] = 1;
}
}
示例10: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description HTML Textfield Driver
* @package Codeine
* @version 8.x
*/
setFn('Make', function ($Call) {
if (is_array($Call['Value'])) {
$Call['Value'] = implode(F::Dot($Call, 'Textarea.Delimiter'), $Call['Value']);
}
$Call = F::Apply('View.HTML.Widget.Base', 'Make', $Call, ['Tag' => 'textarea']);
return $Call;
});
示例11: catch
} catch (MongoException $e) {
return F::Hook('IO.Mongo.Write.Failed', $Call);
}
return isset($Call['Data']) ? $Call['Data'] : null;
});
setFn('Close', function ($Call) {
return true;
});
setFn('Execute', function ($Call) {
F::Log($Call['Command'], LOG_INFO);
return $Call['Link']->execute($Call['Command']);
});
setFn('Count', function ($Call) {
$Call['Scope'] = strtr($Call['Scope'], '.', '_');
if (isset($Call['Where']) and $Call['Where'] !== null) {
$Call = F::Apply(null, 'Where', $Call);
if (isset($Call['Distinct']) && $Call['Distinct']) {
F::Log('db.*' . $Call['Scope'] . '*.distinct(' . j($Call['Where']) . ')', LOG_INFO, 'Administrator');
$Data = $Call['Link']->{$Call}['Scope']->distinct($Call['Fields'][0], $Call['Where']);
return count($Data);
} else {
F::Log('db.*' . $Call['Scope'] . '*.count(' . j($Call['Where']) . ')', LOG_INFO, 'Administrator');
$Cursor = $Call['Link']->{$Call}['Scope']->count($Call['Where']);
}
} else {
if (isset($Call['Distinct']) && $Call['Distinct']) {
F::Log('db.*' . $Call['Scope'] . '*.distinct()', LOG_INFO, 'Administrator');
$Data = $Call['Link']->{$Call}['Scope']->distinct($Call['Fields'][0]);
return count($Data);
} else {
F::Log('db.*' . $Call['Scope'] . '*.count()', LOG_INFO, 'Administrator');
示例12: htmlspecialchars
// Если есть значение, добавляем
if (($Widget['Value'] = F::Dot($Call['Data'], $Name)) === null) {
if (isset($Node['Default'])) {
$Widget['Value'] = F::Live($Node['Default']);
} else {
$Widget['Value'] = null;
}
} else {
$Widget['Value'] = F::Live($Widget['Value']);
}
if (is_scalar($Widget['Value'])) {
$Widget['Value'] = htmlspecialchars($Widget['Value']);
}
// Упростить
if (!isset($Widget['Weight'])) {
$Widget['Weight'] = $IC;
}
// Magic
//$Widget['Label'] .=$Widget['Weight'];
// Помещаем виджет в поток
$Call = F::Apply('Entity.Form.Layout.' . $Call['FormLayout'], 'Add', $Call, ['Name' => $Name, 'Widget' => $Widget]);
$Call['Widget'] = null;
}
}
}
$Call = F::Apply('Entity.Form.Layout.' . $Call['FormLayout'], 'Finish', $Call);
if (isset($Call['Output']['Form'])) {
$Call['Output']['Form'] = F::Sort($Call['Output']['Form'], 'Weight', SORT_ASC);
}
return $Call;
});
示例13: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
$Call = F::Apply('Entity', 'Load', $Call);
if (isset($Call['Where'])) {
$Call['Where'] = F::Live($Call['Where'], $Call);
}
$Call = F::Hook('beforeCount', $Call);
$Call['Count'] = F::Run('Entity', 'Count', $Call);
$Call = F::Hook('afterCount', $Call);
return $Call['Count'];
});
示例14: setFn
<?php
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
$Call = F::Apply('Entity', 'Load', $Call);
$Call = F::Hook('beforeDisallowDo', $Call);
$Call['Where'] = F::Live($Call['Where']);
// FIXME
return F::Run(null, $Call['HTTP']['Method'], $Call);
});
setFn('GET', function ($Call) {
$Call = F::Hook('beforeDisallowGet', $Call);
$Call = F::Apply('Entity.List', 'Do', $Call);
$Call = F::Hook('afterDisallowGet', $Call);
return $Call;
});
setFn('POST', function ($Call) {
$Call = F::Hook('beforeDisallowPost', $Call);
$Call['Data'] = F::Run('Entity', 'Update', $Call, ['Data' => ['Verdict' => $Call['Request']['Verdict'], 'Status' => -1, 'Moderated' => F::Run('System.Time', 'Get', $Call), 'Moderator' => $Call['Session']['User']['ID']]]);
$Call = F::Hook('afterDisallowPost', $Call);
return $Call;
});
示例15: setFn
/* Codeine
* @author bergstein@trickyplan.com
* @description
* @package Codeine
* @version 8.x
*/
setFn('Do', function ($Call) {
if (!isset($Call['Bundle'])) {
$Call['Bundle'] = isset($Call['Start']) ? $Call['Start'] : 'Project';
}
if (!isset($Call['Option'])) {
$Call['Option'] = 'Do';
}
F::Log($Call['Bundle'] . ' ' . $Call['Option'] . ' started', LOG_NOTICE);
$Call = F::loadOptions($Call['Bundle'] . '.Control', null, $Call);
$Call = F::Apply($Call['Bundle'] . '.Control', $Call['Option'], $Call);
$Call['Layouts'][] = ['Scope' => $Call['Bundle'], 'ID' => 'Control'];
$Navigation = [];
F::Log('Control Panel Navigation', LOG_NOTICE);
if (isset($Call['Bundles'])) {
foreach ($Call['Bundles'] as $Group => $Bundles) {
if (in_array($Call['Bundle'], $Bundles)) {
$Call['Group'] = $Group;
}
$GroupOptions = [];
foreach ($Bundles as $Bundle) {
$Options = ['ID' => $Bundle, 'Bundle' => strtr($Bundle, '.', '/'), 'URL' => '/control/' . $Bundle, 'Title' => '<l>' . $Bundle . '.Control:Title</l>', 'Group' => $Group, 'Status' => 'default'];
if (isset($Call['Icons'][$Bundle])) {
$Options['Icon'] = $Call['Icons'][$Bundle];
}
if (($BundleOptions = F::Run($Bundle . '.Control', 'Menu', ['Bundle' => $Bundle])) !== null) {