本文整理汇总了PHP中trigger函数的典型用法代码示例。如果您正苦于以下问题:PHP trigger函数的具体用法?PHP trigger怎么用?PHP trigger使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了trigger函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
/**
* @return mixed
*/
public function execute()
{
$data = $this->loginForm->getRawData(['email', 'password']);
foreach (config('pckg.auth.providers') as $providerKey => $providerConfig) {
/**
* Create and set new provider.
*/
$provider = Reflect::create($providerConfig['type'], [$this->auth]);
$provider->setEntity($providerConfig['entity']);
/**
* If user doesnt exists, don't proceed with execution.
*/
if (!($user = $provider->getUserByEmailAndPassword($data['email'], sha1($data['password'] . $providerConfig['hash'])))) {
continue;
}
/**
* Try to login.
*/
$this->auth->useProvider($provider, $providerKey);
if ($this->auth->performLogin($user)) {
/**
* @T00D00 - login user on all providers!
*/
$this->auth->useProvider($provider);
trigger('user.loggedIn', [$this->auth->getUser()]);
if (isset($data['autologin'])) {
$this->auth->setAutologin();
}
return $this->successful();
}
}
return $this->error();
}
示例2: run
public function run($params)
{
// $oldRevision = 117093;
$oldRevision = self::getPrevRevision();
// $oldRevision = null;
// 检查m3d配置文件是否已改变
$path = defined('M3D_FILE') ? M3D_FILE : (defined('SRC_ROOT') ? SRC_ROOT . '/m3d.php' : null);
if ($path && self::checkFileChange($path, $oldRevision)) {
mark('m3d配置文件已改变,重新加载配置,并且进行全量编译', 'especial');
$params[1]->reload(PROJECT_SITE_PATH . '/' . C('PROJECT.SRC_DIR') . '/' . PROJECT_MODULE_NAME . '/' . C('M3D_FILENAME'));
C('INCRE.IS_INCRE', false);
trigger('m3d_config_change');
}
if (isset($_GET['isIncre']) && $_GET['isIncre'] === 'false' || !C('INCRE.IS_INCRE') || is_null($oldRevision)) {
// 事件解绑
self::off();
} else {
mark('增量编译准备中...', 'emphasize');
$newRevision = IncreMap::getRevision();
self::$files = self::getChangeList($newRevision, $oldRevision);
IncreMap::loadBelongMap();
if (!empty(self::$files[self::DELETE])) {
IncreMap::rebuildBelongMap(self::$files[self::DELETE]);
}
// 更新modify列表
self::$files[self::MODIFY] = array_unique(array_merge(self::$files[self::MODIFY], IncreMap::getAffectList(self::$files[self::MODIFY])));
}
}
示例3: __invoke
function __invoke($error, $method, $path, \cms\Sphido $cms)
{
trigger(MissingPage::class . '_before', $error, $method, $path, $cms);
if ($cms->page = Page::fromPath(\dir\content() . '/404', (array) \app\config()->meta)) {
return $cms->render();
}
trigger(MissingPage::class . '_default', $error, $method, $path, $cms);
}
示例4: latte
/**
* @return Engine
*/
function latte()
{
$latte = new Engine();
$latte->setLoader(filter('latte.loader', new FileLoader()));
$latte->setTempDirectory(\dir\cache());
$latte->addFilter('md', '\\cms\\md');
trigger('latte.macroset', new MacroSet($latte->getCompiler()));
return filter('latte', $latte);
}
示例5: handle
private function handle($matches)
{
$path = Tool::getActualPath($matches[1]);
$processor = new JsPreprocess($this->processor->getMap());
$processor->setFile(C('SRC.SRC_PATH') . $path);
$processor->process();
trigger('js_import', $this->processor, $processor);
return $processor->getContents();
}
示例6: latte
/**
* @return Engine
*/
function latte()
{
$latte = new Engine();
$latte->setLoader(filter(FileLoader::class, new FileLoader()));
$latte->setTempDirectory(\dir\cache());
$latte->addFilter('md', '\\cms\\md');
trigger(MacroSet::class, new MacroSet($latte->getCompiler()));
return filter(Engine::class, $latte);
}
示例7: execute
/**
* @return mixed
*/
public function execute()
{
$rUser->setArray($this->request->post());
$rUser->hashPassword();
if ($rUser->save()) {
trigger('user.registered', [$rUser]);
return $this->successful();
}
return $this->error();
}
示例8: replaceMediaPath
private function replaceMediaPath($matches)
{
$path = $matches[0];
$aPath = Tool::getActualPath($path);
if (isset($this->map['media'][$aPath])) {
trigger('js_replace', $this, $aPath);
return Tool::addCdn($this->map['media'][$aPath]);
}
return $path;
}
示例9: run
public function run()
{
trigger('imerge_start', $this);
mark('开始自动合图扫描', 'emphasize');
$files = get_files_by_type(C('SRC.SRC_PATH'), 'css');
$generator = new MergeConfigGenerator($files);
$generator->generate();
$writer = new MergeConfigWriter(C('IMERGE_PATH'));
$writer->writeImageConfig($generator->getConfig());
// 更新大图
$this->updateSprite();
trigger('imerge_end', $this);
}
示例10: getInstance
public static final function getInstance($class, $options = null)
{
if (empty($class)) {
return null;
}
$class = ucfirst(strtolower($class)) . 'Compressor';
if (!isset(self::$_instance[$class])) {
$instance = new stdClass();
$instance->return = null;
trigger('get_compressor', $instance, $options);
self::$_instance[$class] = is_null($instance->return) ? empty($options) ? new $class() : new $class($options) : $instance->return;
}
return self::$_instance[$class];
}
示例11: publishMETA
public function publishMETA()
{
$title = trigger('page_title', $this->pageTitle);
if (empty($title) || !isset($title)) {
publish('<title>' . $this->pageTitle . '</title>');
} else {
publish('<title>' . $title . '</title>');
}
publish('<meta name="description" content="' . $this->pageDesc . '">');
publish('<meta name="keywords" content="' . $this->pageTags . '">');
if (isset($_SERVER['HTTP_USER_AGENT']) && strpos($_SERVER['HTTP_USER_AGENT'], 'MSIE') !== false) {
publish('<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1"/>');
}
publish('<script>var resourceURL = "/' . currentSite()->relativePath . 'res/' . '";</script>');
}
示例12: error
/**
* Page not found error.
*
* @param $error
* @param callable $method
* @param string $path
* @param Sphido $cms
* @return int|null
*/
public function error($error, $method, $path, $cms)
{
trigger('render.error', $error, $method, $path, $cms);
if ($this->page = Page::fromPath(\dir\content() . '/404', (array) config()->meta)) {
return print ensure('render.error', [$this, 'render'], $this);
}
/**
* @param int $error
* @param string $method
* @param string $path
* @param Sphido $cms
* @name render .default.error
*/
ensure('render.default.error', $error, $method, $path, $cms);
// default error is on you
}
示例13: render
/**
* @return mixed|null|string
* @throws \Exception
*/
public function render()
{
trigger(Sphido::class . '::' . __FUNCTION__, $this->page, $this);
// HTTP status code
if ($code = isset($this->page->status) ? $this->page->status : null) {
http_response_code($code);
}
// PHTML file execute
if ($this->page->is('phtml')) {
extract(get_object_vars($this), EXTR_SKIP);
ob_start();
require $this->page;
return ob_get_clean();
}
return latte()->renderToString($this->page, get_object_vars($this));
}
示例14: run
public function run($params)
{
$item = $params[2];
if ($this->options['requirejs.path'] && $item['processor'] === 'js') {
mark('requireJs插件开始处理' . $this->options['requirejs.path'], 'emphasize');
$this->options['requirejs.path'] = C('SRC.SRC_PATH') . $this->options['requirejs.path'];
if (!file_exists($this->options['requirejs.path'])) {
mark('"' . $this->options['requirejs.path'] . '"不存在,请检查m3d.php中requireJs配置', 'error');
return;
}
$tool = $params[1];
$map = $this->getMap($tool);
$script = $this->genScript($map);
$processor = Preprocess::getInstance('js');
$mapFiles = $this->options['requirejs.path'];
if (is_string($mapFiles)) {
$mapFiles = array($mapFiles);
}
foreach ($mapFiles as $file) {
$processor->setFile($file);
$processor->setContents($script);
$processor->process();
$processor->compress();
$path = $processor->getRelativePath();
$buildPath = $tool->writeBuildFile($processor, $item, $path);
$oldBuildPath = $tool->getMap('js', $path);
if ($buildPath !== $oldBuildPath) {
$tool->updateMap('js', $path, $buildPath);
// 清除文件
$file = C('SRC.BUILD_PATH') . $oldBuildPath;
if (file_exists($file)) {
unlink($file);
}
$file = C('SRC.BUILD_CACHE_PATH') . $oldBuildPath;
if (file_exists($file)) {
unlink($file);
}
trigger('change_file', $path);
}
}
}
}
示例15: draw
/**
* 绘制图像
* @param $type
*/
public function draw($type, $config = array())
{
if (empty($config)) {
$loader = new MergeConfigLoader($this->imergePath);
$config = $loader->getImageConfigByType($type);
}
$imgList = array();
if (!empty($config)) {
foreach ($config as $key => $value) {
try {
$imgList[$key] = new Image($this->staticRelativePath . $key, $value);
} catch (ImageException $e) {
mark("合图{$type}中,存在小图{$key}的配置文件,但该小图不存在,请到合图配置界面删除该小图", 'warn');
}
}
}
$layout = new Layout($imgList);
$spriteConfigs = array();
$spriteConfigs[$type] = array();
if ($layout->reflow($width, $height)) {
$this->sprite = imagecreatetruecolor($width, $height);
imagealphablending($this->sprite, false);
imagesavealpha($this->sprite, true);
imagefill($this->sprite, 0, 0, imagecolorallocatealpha($this->sprite, 0, 0, 0, 127));
$spriteConfigs[$type]['config'] = $this->repaint($this->sprite, $imgList, $width, $height);
// 记录sprite的属性
$spriteConfigs[$type]['attr'] = array('filename' => $type . C('SPRITE_SUFFIX') . '.png', 'width' => $width, 'height' => $height);
// $spriteConfigs[$type]['filename'] = $type.C('SPRITE_SUFFIX').'.png';
// 生成大图到imerge_sprite_dir
$path = $this->imergePath . '/' . C('IMERGE_SPRITE_DIR') . '/' . $type . C('SPRITE_SUFFIX') . '.png';
imagepng($this->sprite, $path);
// 写入配置
$writer = new MergeConfigWriter($this->imergePath);
$writer->writeSpriteConfig($spriteConfigs);
// 派发处理完成事件
trigger('DRAW_SPRITE_END', $path);
}
}