repository_name
stringlengths 5
67
| func_path_in_repository
stringlengths 4
234
| func_name
stringlengths 0
314
| whole_func_string
stringlengths 52
3.87M
| language
stringclasses 6
values | func_code_string
stringlengths 52
3.87M
| func_documentation_string
stringlengths 1
47.2k
| func_code_url
stringlengths 85
339
|
---|---|---|---|---|---|---|---|
as3io/modlr | src/Api/AbstractAdapter.php | AbstractAdapter.handleException | public function handleException(\Exception $e)
{
if (extension_loaded('newrelic')) {
newrelic_notice_error($e->getMessage(), $e);
}
$refl = new \ReflectionClass($e);
if ($e instanceof HttpExceptionInterface) {
$title = sprintf('%s::%s', $refl->getShortName(), $e->getErrorType());
$detail = $e->getMessage();
$status = $e->getHttpCode();
} else {
$title = $refl->getShortName();
$detail = 'Oh no! Something bad happened on the server! Please try again.';
$status = 500;
}
$serialized = $this->getSerializer()->serializeError($title, $detail, $status);
$payload = new Rest\RestPayload($serialized);
return $this->createRestResponse($status, $payload);
} | php | public function handleException(\Exception $e)
{
if (extension_loaded('newrelic')) {
newrelic_notice_error($e->getMessage(), $e);
}
$refl = new \ReflectionClass($e);
if ($e instanceof HttpExceptionInterface) {
$title = sprintf('%s::%s', $refl->getShortName(), $e->getErrorType());
$detail = $e->getMessage();
$status = $e->getHttpCode();
} else {
$title = $refl->getShortName();
$detail = 'Oh no! Something bad happened on the server! Please try again.';
$status = 500;
}
$serialized = $this->getSerializer()->serializeError($title, $detail, $status);
$payload = new Rest\RestPayload($serialized);
return $this->createRestResponse($status, $payload);
} | {@inheritDoc} | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Api/AbstractAdapter.php#L212-L231 |
as3io/modlr | src/Api/AbstractAdapter.php | AbstractAdapter.serialize | public function serialize(Model $model = null)
{
$serialized = (String) $this->getSerializer()->serialize($model, $this);
$this->validateSerialization($serialized);
return new Rest\RestPayload($serialized);
} | php | public function serialize(Model $model = null)
{
$serialized = (String) $this->getSerializer()->serialize($model, $this);
$this->validateSerialization($serialized);
return new Rest\RestPayload($serialized);
} | {@inheritDoc} | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Api/AbstractAdapter.php#L268-L273 |
as3io/modlr | src/Api/AbstractAdapter.php | AbstractAdapter.serializeArray | public function serializeArray(array $models)
{
$serialized = (String) $this->getSerializer()->serializeArray($models, $this);
$this->validateSerialization($serialized);
return new Rest\RestPayload($serialized);
} | php | public function serializeArray(array $models)
{
$serialized = (String) $this->getSerializer()->serializeArray($models, $this);
$this->validateSerialization($serialized);
return new Rest\RestPayload($serialized);
} | {@inheritDoc} | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Api/AbstractAdapter.php#L278-L283 |
as3io/modlr | src/Api/AbstractAdapter.php | AbstractAdapter.serializeCollection | public function serializeCollection(Collection $collection)
{
$serialized = (String) $this->getSerializer()->serializeCollection($collection, $this);
$this->validateSerialization($serialized);
return new Rest\RestPayload($serialized);
} | php | public function serializeCollection(Collection $collection)
{
$serialized = (String) $this->getSerializer()->serializeCollection($collection, $this);
$this->validateSerialization($serialized);
return new Rest\RestPayload($serialized);
} | {@inheritDoc} | https://github.com/as3io/modlr/blob/7e684b88bb22a2e18397df9402075c6533084b16/src/Api/AbstractAdapter.php#L288-L293 |
kleijnweb/php-api-middleware | src/CommandDispatcher.php | CommandDispatcher.process | public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
$operation = $this->getOperation($request);
$arguments = [];
foreach ($operation->getParameters() as $parameter) {
$arguments[] = $request->getAttribute($parameter->getName());
}
$result = call_user_func_array($this->commands[$operation->getId()], $arguments);
return $delegate->process($request->withAttribute(self::ATTRIBUTE, $result));
} | php | public function process(ServerRequestInterface $request, DelegateInterface $delegate)
{
$operation = $this->getOperation($request);
$arguments = [];
foreach ($operation->getParameters() as $parameter) {
$arguments[] = $request->getAttribute($parameter->getName());
}
$result = call_user_func_array($this->commands[$operation->getId()], $arguments);
return $delegate->process($request->withAttribute(self::ATTRIBUTE, $result));
} | Process a server request and return a response.
@param ServerRequestInterface $request
@param DelegateInterface $delegate
@return ResponseInterface | https://github.com/kleijnweb/php-api-middleware/blob/e9e74706c3b30a0e06c7f0f7e2a3a43ef17e6df4/src/CommandDispatcher.php#L54-L66 |
cyberspectrum/i18n-contao | src/Extractor/ConditionalMultiStringExtractor.php | ConditionalMultiStringExtractor.supports | public function supports(array $row): bool
{
return parent::supports($row) && $this->delegate->supports($row);
} | php | public function supports(array $row): bool
{
return parent::supports($row) && $this->delegate->supports($row);
} | {@inheritDoc} | https://github.com/cyberspectrum/i18n-contao/blob/038cf6ea9c609a734d7476fba256bc4b0db236b7/src/Extractor/ConditionalMultiStringExtractor.php#L57-L60 |
cyberspectrum/i18n-contao | src/Extractor/ConditionalMultiStringExtractor.php | ConditionalMultiStringExtractor.get | public function get(string $path, array $row): ?string
{
return $this->delegate->get($path, $row);
} | php | public function get(string $path, array $row): ?string
{
return $this->delegate->get($path, $row);
} | {@inheritDoc} | https://github.com/cyberspectrum/i18n-contao/blob/038cf6ea9c609a734d7476fba256bc4b0db236b7/src/Extractor/ConditionalMultiStringExtractor.php#L73-L76 |
codemaxbr/reliese | src/Meta/Blueprint.php | Blueprint.isUniqueKey | public function isUniqueKey(Fluent $constraint)
{
$is = false;
foreach ($this->unique as $index) {
foreach ($index->columns as $column) {
$is &= in_array($column, $constraint->columns);
}
if ($is) {
return true;
}
}
return $is;
} | php | public function isUniqueKey(Fluent $constraint)
{
$is = false;
foreach ($this->unique as $index) {
foreach ($index->columns as $column) {
$is &= in_array($column, $constraint->columns);
}
if ($is) {
return true;
}
}
return $is;
} | @param \Illuminate\Support\Fluent $constraint
@return bool | https://github.com/codemaxbr/reliese/blob/efaac021ba4d936edd7e9fda2bd7bcdac18d8497/src/Meta/Blueprint.php#L261-L275 |
newup/core | src/Providers/FilesystemServiceProvider.php | FilesystemServiceProvider.register | public function register()
{
$this->app->bind(FilesystemContract::class, Filesystem::class);
$this->app->singleton(StorageEngine::class, function () {
return new TemplateStorageEngine(app(FilesystemContract::class),
app(Composer::class),
template_storage_path(),
app(Log::class)
);
});
$this->app->singleton(SearchableStorageEngine::class, StorageEngine::class);
$this->app->singleton(AutoLoaderManager::class, function() {
return new AutoLoaderManager(app(FilesystemContract::class), app(), app(Log::class));
});
} | php | public function register()
{
$this->app->bind(FilesystemContract::class, Filesystem::class);
$this->app->singleton(StorageEngine::class, function () {
return new TemplateStorageEngine(app(FilesystemContract::class),
app(Composer::class),
template_storage_path(),
app(Log::class)
);
});
$this->app->singleton(SearchableStorageEngine::class, StorageEngine::class);
$this->app->singleton(AutoLoaderManager::class, function() {
return new AutoLoaderManager(app(FilesystemContract::class), app(), app(Log::class));
});
} | Register the service provider.
@return void | https://github.com/newup/core/blob/54128903e7775e67d63284d958b46862c8df71f9/src/Providers/FilesystemServiceProvider.php#L22-L39 |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Framework/Media/Media/Domain/ProxyDomain.php | ProxyDomain.registerMediaDomain | public function registerMediaDomain($extensions, DomainInterface $mediaDomain)
{
foreach ((array) $extensions as $extensions) {
$this->mediaDomainsMap[strtolower($extensions)] = $mediaDomain;
}
} | php | public function registerMediaDomain($extensions, DomainInterface $mediaDomain)
{
foreach ((array) $extensions as $extensions) {
$this->mediaDomainsMap[strtolower($extensions)] = $mediaDomain;
}
} | Register a media domain for given file extension set.
@param string|array $extensions
@param DomainInterface $mediaDomain | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Framework/Media/Media/Domain/ProxyDomain.php#L37-L42 |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Framework/Media/Media/Domain/ProxyDomain.php | ProxyDomain.fetchDomain | private function fetchDomain($extension)
{
if (!array_key_exists($extension = strtolower($extension), $this->mediaDomainsMap)) {
throw new UnsupportedFileException(sprintf(
'Extension ".%s" isnt supported by Media component, only ["%s"] are.',
$extension,
implode('", "', array_keys($this->mediaDomainsMap))
));
}
return $this->mediaDomainsMap[$extension];
} | php | private function fetchDomain($extension)
{
if (!array_key_exists($extension = strtolower($extension), $this->mediaDomainsMap)) {
throw new UnsupportedFileException(sprintf(
'Extension ".%s" isnt supported by Media component, only ["%s"] are.',
$extension,
implode('", "', array_keys($this->mediaDomainsMap))
));
}
return $this->mediaDomainsMap[$extension];
} | Fetch and return domain matching given file extension.
@param string $extension
@return DomainInterface
@throws UnsupportedFileException If given extension isnt supported | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Framework/Media/Media/Domain/ProxyDomain.php#L53-L64 |
inhere/php-library-plus | libs/Auth/User.php | User.can | public function can($permission, array $params = [], $caching = true)
{
return $this->canAccess($permission, $params, $caching);
} | php | public function can($permission, array $params = [], $caching = true)
{
return $this->canAccess($permission, $params, $caching);
} | check user permission
@param string $permission a permission name or a url
@param array $params
@param bool|true $caching
@return bool | https://github.com/inhere/php-library-plus/blob/8604e037937d31fa2338d79aaf9d0910cb48f559/libs/Auth/User.php#L162-L165 |
PHPColibri/framework | Session/Session.php | Session.start | public static function start()
{
$driver = self::getDriver();
self::$storage = $driver::getInstance();
self::$flashedVars = self::$storage->remove('flashed');
} | php | public static function start()
{
$driver = self::getDriver();
self::$storage = $driver::getInstance();
self::$flashedVars = self::$storage->remove('flashed');
} | Starts the Session. | https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Session/Session.php#L29-L35 |
PHPColibri/framework | Session/Session.php | Session.get | public static function get($dottedKey, $default = null)
{
if (self::$flashedVars) {
$flashedValue = Arr::get(self::$flashedVars, $dottedKey, '~no~flashed~value~');
if ($flashedValue !== '~no~flashed~value~') {
return $flashedValue;
}
}
return self::$storage->get($dottedKey, $default);
} | php | public static function get($dottedKey, $default = null)
{
if (self::$flashedVars) {
$flashedValue = Arr::get(self::$flashedVars, $dottedKey, '~no~flashed~value~');
if ($flashedValue !== '~no~flashed~value~') {
return $flashedValue;
}
}
return self::$storage->get($dottedKey, $default);
} | Retrieve the value from session.
@param string $dottedKey
@param mixed $default
@return mixed | https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Session/Session.php#L53-L63 |
PHPColibri/framework | Session/Session.php | Session.setDriver | public static function setDriver(string $driver)
{
if ( ! self::isValidDriver($driver)) {
throw new \InvalidArgumentException("invalid session driver '$driver'");
}
self::$driver = $driver;
} | php | public static function setDriver(string $driver)
{
if ( ! self::isValidDriver($driver)) {
throw new \InvalidArgumentException("invalid session driver '$driver'");
}
self::$driver = $driver;
} | @param string $driver name of class that implements \Colibri\Session\Storage\StorageInterface
@throws \InvalidArgumentException | https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Session/Session.php#L137-L144 |
PHPColibri/framework | Session/Session.php | Session.isValidDriver | private static function isValidDriver(string $driver): bool
{
return
class_exists($driver) &&
Arr::contains(class_implements($driver), StorageInterface::class);
} | php | private static function isValidDriver(string $driver): bool
{
return
class_exists($driver) &&
Arr::contains(class_implements($driver), StorageInterface::class);
} | @param string $driver
@return bool | https://github.com/PHPColibri/framework/blob/7e5b77141da5e5e7c63afc83592671321ac52f36/Session/Session.php#L151-L156 |
cymapgt/logger | src/Logger.php | Logger.addLogHandler | public function addLogHandler(array $logHandlers, $createLogger = false) {
try {
$this->configuredLogHandlers = array_merge($this->configuredLogHandlers, $logHandlers);
if ($createLogger === true) {
$this->createLogger($this->channelName);
$this->createLogHandlers();
}
} catch (Exception $ex) {
throw new LoggerException (
"An exception occurred when adding the Log Handler to "
. $this->channelName
. ":"
. $ex->getMessage()
);
}
} | php | public function addLogHandler(array $logHandlers, $createLogger = false) {
try {
$this->configuredLogHandlers = array_merge($this->configuredLogHandlers, $logHandlers);
if ($createLogger === true) {
$this->createLogger($this->channelName);
$this->createLogHandlers();
}
} catch (Exception $ex) {
throw new LoggerException (
"An exception occurred when adding the Log Handler to "
. $this->channelName
. ":"
. $ex->getMessage()
);
}
} | Add log handlers to the configuration
@param array $logHandlers - Array of log handler configuration. The alphanumeric keys are the namespace
@param bool $createLogger - Boolean flag. If true, create concrete Logger and instantiate the log handlers | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L72-L88 |
cymapgt/logger | src/Logger.php | Logger.createLogHandlers | protected function createLogHandlers() {
$logHandlers = $this->configuredLogHandlers;
foreach ($logHandlers as $handlerNamespace => $handlerDetails) {
if (
is_array($handlerDetails)
&& array_key_exists('handler_parameters', $handlerDetails)
) {
$handlerParameters = $handlerDetails['handler_parameters'];
$handlerObj = new $handlerNamespace(...$handlerParameters);
$this->concreteLogger->pushHandler($handlerObj);
}
}
} | php | protected function createLogHandlers() {
$logHandlers = $this->configuredLogHandlers;
foreach ($logHandlers as $handlerNamespace => $handlerDetails) {
if (
is_array($handlerDetails)
&& array_key_exists('handler_parameters', $handlerDetails)
) {
$handlerParameters = $handlerDetails['handler_parameters'];
$handlerObj = new $handlerNamespace(...$handlerParameters);
$this->concreteLogger->pushHandler($handlerObj);
}
}
} | Iterate the configured log handlers and create concrete handlers | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L102-L115 |
cymapgt/logger | src/Logger.php | Logger.getLogger | public static function getLogger($loggerType, $loggerParams = array()) {
//trap all possible exceptions and throw LoggerException
try {
switch ($loggerType) {
case LOGGER_STDERR:
return self::_getLoggerStderr();
case LOGGER_LEVEL1:
return self::_getLoggerLevel1($loggerParams);
case LOGGER_LEVEL2:
return self::_getLoggerLevel2($loggerParams);
case LOGGER_LEVEL3:
return self::_getLoggerLevel3($loggerParams);
case LOGGER_SECURITY:
return self::_getLoggerSecurity($loggerParams);
}
} catch (\Exception $logException) {
throw new LoggerException('Logger caught an exception in '
. $logException->getTraceAsString() . ':'
. $logException->getMessage(), 1001);
}
} | php | public static function getLogger($loggerType, $loggerParams = array()) {
//trap all possible exceptions and throw LoggerException
try {
switch ($loggerType) {
case LOGGER_STDERR:
return self::_getLoggerStderr();
case LOGGER_LEVEL1:
return self::_getLoggerLevel1($loggerParams);
case LOGGER_LEVEL2:
return self::_getLoggerLevel2($loggerParams);
case LOGGER_LEVEL3:
return self::_getLoggerLevel3($loggerParams);
case LOGGER_SECURITY:
return self::_getLoggerSecurity($loggerParams);
}
} catch (\Exception $logException) {
throw new LoggerException('Logger caught an exception in '
. $logException->getTraceAsString() . ':'
. $logException->getMessage(), 1001);
}
} | Static function to return an instance of a logger
@param int loggerType - The logger type
@param array loggerParams - array of logger params
@return self::$dbLink - Returns static instance of mysqli connection
@public
@static | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L149-L169 |
cymapgt/logger | src/Logger.php | Logger._getLoggerStderr | private static function _getLoggerStderr() {
if (!isset(self::$loggerStderr)) {
$CymapgtStderrLogger = new MonologLogger('cymapgt_stderr');
$CymapgtStderrLogger->pushHandler(new ErrorLogHandler());
self::$loggerStderr = $CymapgtStderrLogger;
}
return self::$loggerStderr;
} | php | private static function _getLoggerStderr() {
if (!isset(self::$loggerStderr)) {
$CymapgtStderrLogger = new MonologLogger('cymapgt_stderr');
$CymapgtStderrLogger->pushHandler(new ErrorLogHandler());
self::$loggerStderr = $CymapgtStderrLogger;
}
return self::$loggerStderr;
} | return the stderr logger
@return object
@private
@static | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L179-L186 |
cymapgt/logger | src/Logger.php | Logger._getLoggerLevel1 | private static function _getLoggerLevel1($loggerParams) {
if (!isset(self::$loggerLevel1)) {
$CymapgtLevel1LogDir = $loggerParams['log_dir'];
$CymapgtLevel1Stream = new StreamHandler($CymapgtLevel1LogDir, MonologLogger::DEBUG);
$CymapgtLevel1Logger = new MonologLogger('cymapgt_level1');
$CymapgtLevel1Logger->pushHandler($CymapgtLevel1Stream);
self::$loggerLevel1 = $CymapgtLevel1Logger;
}
return self::$loggerLevel1;
} | php | private static function _getLoggerLevel1($loggerParams) {
if (!isset(self::$loggerLevel1)) {
$CymapgtLevel1LogDir = $loggerParams['log_dir'];
$CymapgtLevel1Stream = new StreamHandler($CymapgtLevel1LogDir, MonologLogger::DEBUG);
$CymapgtLevel1Logger = new MonologLogger('cymapgt_level1');
$CymapgtLevel1Logger->pushHandler($CymapgtLevel1Stream);
self::$loggerLevel1 = $CymapgtLevel1Logger;
}
return self::$loggerLevel1;
} | return the level1 logger
@param array $loggerParams - Array of parameters to configure the level 1 logger
@return object
@private
@static | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L197-L206 |
cymapgt/logger | src/Logger.php | Logger._getLoggerLevel2 | private static function _getLoggerLevel2($loggerParams) {
if (!isset(self::$loggerLevel2)) {
$CymapgtLevel2LogDir = $loggerParams['log_dir'];
$CymapgtLevel2Stream = new StreamHandler($CymapgtLevel2LogDir, MonologLogger::ERROR);
$CymapgtLevel2Logger = new MonologLogger('cymapgt_level2');
$CymapgtLevel2Mailer = new \Swift_Mailer($loggerParams['swiftmailer_transport']);
$CymapgtLevel2Message = $loggerParams['swiftmailer_message'];
$CymapgtLevel2Logger->pushHandler($CymapgtLevel2Stream);
$CymapgtLevel2Logger->pushHandler(new SwiftMailerHandler($CymapgtLevel2Mailer, $CymapgtLevel2Message));
self::$loggerLevel2 = $CymapgtLevel2Logger;
}
return self::$loggerLevel2;
} | php | private static function _getLoggerLevel2($loggerParams) {
if (!isset(self::$loggerLevel2)) {
$CymapgtLevel2LogDir = $loggerParams['log_dir'];
$CymapgtLevel2Stream = new StreamHandler($CymapgtLevel2LogDir, MonologLogger::ERROR);
$CymapgtLevel2Logger = new MonologLogger('cymapgt_level2');
$CymapgtLevel2Mailer = new \Swift_Mailer($loggerParams['swiftmailer_transport']);
$CymapgtLevel2Message = $loggerParams['swiftmailer_message'];
$CymapgtLevel2Logger->pushHandler($CymapgtLevel2Stream);
$CymapgtLevel2Logger->pushHandler(new SwiftMailerHandler($CymapgtLevel2Mailer, $CymapgtLevel2Message));
self::$loggerLevel2 = $CymapgtLevel2Logger;
}
return self::$loggerLevel2;
} | return the level2 logger
@param array $loggerParams - Array of parameters to configure the level 2 logger
@return object
@private
@static | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L217-L229 |
cymapgt/logger | src/Logger.php | Logger._getLoggerLevel3 | private static function _getLoggerLevel3($loggerParams) {
if (!isset(self::$loggerLevel3)) {
/*create notifier object for africas talking. If you are behind a proxy, the
*second parameter should be true, and your configuration array should contain
*the proxy server settings
*/
$notifierObj = new NotifierSmsAfricasTalkingService($loggerParams['notifier_params'], true);
$recipientList = $loggerParams['notifier_recipients'];
$CymapgtLevel3LogDir = $loggerParams['log_dir'];
$CymapgtLevel3Stream = new StreamHandler($CymapgtLevel3LogDir, MonologLogger::ERROR);
$CymapgtLevel3Logger = new MonologLogger('cymapgt_level3');
$CymapgtLevel3Mailer = new \Swift_Mailer($loggerParams['swiftmailer_transport']);
$CymapgtLevel3Message = $loggerParams['swiftmailer_message'];
$CymapgtLevel3Logger->pushHandler($CymapgtLevel3Stream);
$CymapgtLevel3Logger->pushHandler(new SwiftMailerHandler($CymapgtLevel3Mailer, $CymapgtLevel3Message));
$smsHandler = new NotifierSmsAfricasTalkingServiceHandler($notifierObj);
$smsHandler->setRecipients($recipientList);
$CymapgtLevel3Logger->pushHandler($smsHandler);
self::$loggerLevel3 = $CymapgtLevel3Logger;
}
return self::$loggerLevel3;
} | php | private static function _getLoggerLevel3($loggerParams) {
if (!isset(self::$loggerLevel3)) {
/*create notifier object for africas talking. If you are behind a proxy, the
*second parameter should be true, and your configuration array should contain
*the proxy server settings
*/
$notifierObj = new NotifierSmsAfricasTalkingService($loggerParams['notifier_params'], true);
$recipientList = $loggerParams['notifier_recipients'];
$CymapgtLevel3LogDir = $loggerParams['log_dir'];
$CymapgtLevel3Stream = new StreamHandler($CymapgtLevel3LogDir, MonologLogger::ERROR);
$CymapgtLevel3Logger = new MonologLogger('cymapgt_level3');
$CymapgtLevel3Mailer = new \Swift_Mailer($loggerParams['swiftmailer_transport']);
$CymapgtLevel3Message = $loggerParams['swiftmailer_message'];
$CymapgtLevel3Logger->pushHandler($CymapgtLevel3Stream);
$CymapgtLevel3Logger->pushHandler(new SwiftMailerHandler($CymapgtLevel3Mailer, $CymapgtLevel3Message));
$smsHandler = new NotifierSmsAfricasTalkingServiceHandler($notifierObj);
$smsHandler->setRecipients($recipientList);
$CymapgtLevel3Logger->pushHandler($smsHandler);
self::$loggerLevel3 = $CymapgtLevel3Logger;
}
return self::$loggerLevel3;
} | return the level3 logger
@param array $loggerParams - Array of parameters to configure the level 3 logger
@return object
@private
@static | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L240-L262 |
cymapgt/logger | src/Logger.php | Logger._getLoggerSecurity | private static function _getLoggerSecurity($loggerParams) {
if (!isset(self::$loggerSecurity)) {
/*create notifier object for africas talking. If you are behind a proxy, the
*second parameter should be true, and your configuration array should contain
*the proxy server settings
*/
$notifierObj = new NotifierSmsAfricasTalkingService(($loggerParams['notifier_params']), ($loggerParams['notifier_params']['IS_BEHIND_PROXY']));
$recipientList = $loggerParams['notifier_recipients'];
$CymapgtSecurityLogDir = $loggerParams['log_dir'];
$CymapgtSecurityStream = new StreamHandler($CymapgtSecurityLogDir, MonologLogger::ERROR);
$CymapgtSecurityLogger = new MonologLogger('cymapgt_security');
$CymapgtSecurityMailer = new \Swift_Mailer($loggerParams['swiftmailer_transport']);
$CymapgtSecurityMessage = $loggerParams['swiftmailer_message'];
$CymapgtSecurityLogger->pushHandler($CymapgtSecurityStream);
$CymapgtSecurityLogger->pushHandler(new SwiftMailerHandler($CymapgtSecurityMailer, $CymapgtSecurityMessage));
$smsHandler = new NotifierSmsAfricasTalkingServiceHandler($notifierObj);
$smsHandler->setRecipients($recipientList);
$CymapgtSecurityLogger->pushHandler($smsHandler);
self::$loggerSecurity = $CymapgtSecurityLogger;
}
return self::$loggerSecurity;
} | php | private static function _getLoggerSecurity($loggerParams) {
if (!isset(self::$loggerSecurity)) {
/*create notifier object for africas talking. If you are behind a proxy, the
*second parameter should be true, and your configuration array should contain
*the proxy server settings
*/
$notifierObj = new NotifierSmsAfricasTalkingService(($loggerParams['notifier_params']), ($loggerParams['notifier_params']['IS_BEHIND_PROXY']));
$recipientList = $loggerParams['notifier_recipients'];
$CymapgtSecurityLogDir = $loggerParams['log_dir'];
$CymapgtSecurityStream = new StreamHandler($CymapgtSecurityLogDir, MonologLogger::ERROR);
$CymapgtSecurityLogger = new MonologLogger('cymapgt_security');
$CymapgtSecurityMailer = new \Swift_Mailer($loggerParams['swiftmailer_transport']);
$CymapgtSecurityMessage = $loggerParams['swiftmailer_message'];
$CymapgtSecurityLogger->pushHandler($CymapgtSecurityStream);
$CymapgtSecurityLogger->pushHandler(new SwiftMailerHandler($CymapgtSecurityMailer, $CymapgtSecurityMessage));
$smsHandler = new NotifierSmsAfricasTalkingServiceHandler($notifierObj);
$smsHandler->setRecipients($recipientList);
$CymapgtSecurityLogger->pushHandler($smsHandler);
self::$loggerSecurity = $CymapgtSecurityLogger;
}
return self::$loggerSecurity;
} | return the security logger
@param array $loggerParams - Array of parameters to configure the security logger
@return object
@private
@static | https://github.com/cymapgt/logger/blob/8d042b21a9e13a3597c99084229781ab6151d78f/src/Logger.php#L273-L295 |
IStranger/yii2-resource-smart-load | base/BaseObject.php | BaseObject.setProperties | public function setProperties($propValues)
{
foreach ($propValues as $propName => $propValue) {
if (property_exists($this, $propName)) {
$this->{$propName} = $propValue;
} else {
$this->throwException('Property "%propName%" does not exist in class "%className%"', array(
'%propName%' => $propName,
'%className%' => static::className(),
));
}
}
} | php | public function setProperties($propValues)
{
foreach ($propValues as $propName => $propValue) {
if (property_exists($this, $propName)) {
$this->{$propName} = $propValue;
} else {
$this->throwException('Property "%propName%" does not exist in class "%className%"', array(
'%propName%' => $propName,
'%className%' => static::className(),
));
}
}
} | Sets properties values
@param array $propValues Array of properties values in format: ['propName' => 'propValue'] | https://github.com/IStranger/yii2-resource-smart-load/blob/a4f203745d9a02fd97853b49c55b287aea6d7e6d/base/BaseObject.php#L28-L40 |
chilimatic/chilimatic-framework | lib/route/routesystem/RouteSystemFactory.php | RouteSystemFactory.make | public static function make($type = 'Default', $param)
{
$className = __NAMESPACE__ . "\\{$type}Route";
if (!class_exists($className)) return null;
return new $className($param);
} | php | public static function make($type = 'Default', $param)
{
$className = __NAMESPACE__ . "\\{$type}Route";
if (!class_exists($className)) return null;
return new $className($param);
} | @param string $type
@return AbstractRoute | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/route/routesystem/RouteSystemFactory.php#L24-L31 |
yii2lab/yii2-rbac | src/console/controllers/RuleController.php | RuleController.actionAdd | public function actionAdd()
{
Question::confirm(null, 1);
$collection = \App::$domain->rbac->rule->searchInAllApps();
$rules = \App::$domain->rbac->rule->insertBatch($collection);
if($rules) {
Output::items($rules, "Added " . count($rules) . " rules");
} else {
Output::block("All rules exists!");
}
} | php | public function actionAdd()
{
Question::confirm(null, 1);
$collection = \App::$domain->rbac->rule->searchInAllApps();
$rules = \App::$domain->rbac->rule->insertBatch($collection);
if($rules) {
Output::items($rules, "Added " . count($rules) . " rules");
} else {
Output::block("All rules exists!");
}
} | Search and add RBAC rules | https://github.com/yii2lab/yii2-rbac/blob/e72ac0359af660690c161451f864208b2d20919d/src/console/controllers/RuleController.php#L16-L26 |
wartw98/core | Payment/Observer/ColumnPrepare.php | ColumnPrepare.execute | function execute(O $o) {
/** @var Column $c */
$c = $o[Plugin::COLUMN];
if ('payment_method' === $c->getName()
&& 'sales_order_grid' === $c->getContext()->getNamespace()
) {
$c['config'] = [
'bodyTmpl' => 'ui/grid/cells/html'
,'component' => 'Df_Ui/js/grid/columns/select'
] + $c['config'];
}
} | php | function execute(O $o) {
/** @var Column $c */
$c = $o[Plugin::COLUMN];
if ('payment_method' === $c->getName()
&& 'sales_order_grid' === $c->getContext()->getNamespace()
) {
$c['config'] = [
'bodyTmpl' => 'ui/grid/cells/html'
,'component' => 'Df_Ui/js/grid/columns/select'
] + $c['config'];
}
} | 2016-07-28
@override
@see ObserverInterface::execute()
@used-by \Magento\Framework\Event\Invoker\InvokerDefault::_callObserverMethod()
@param O $o | https://github.com/wartw98/core/blob/e1f44f6b4798a7b988f6a1cae639ff3745c9cd2a/Payment/Observer/ColumnPrepare.php#L42-L53 |
TangoMan75/EntityHelper | Traits/HasLabel.php | HasLabel.setLabel | public function setLabel($label)
{
if (in_array(
$label,
$this->validLabels
)) {
$this->label = $label;
}
return $this;
} | php | public function setLabel($label)
{
if (in_array(
$label,
$this->validLabels
)) {
$this->label = $label;
}
return $this;
} | @param string $label
@return $this | https://github.com/TangoMan75/EntityHelper/blob/588a51dabdbc5dfa213547ce7561d2674aab83df/Traits/HasLabel.php#L59-L69 |
feelinc/laravel-api | src/Sule/Api/Commands/NewOAuthClient.php | NewOAuthClient.fire | public function fire()
{
$clientName = $this->argument('name');
$clientId = $this->option('id');
$clientSecret = $this->option('secret');
if (empty($clientId)) {
$clientId = Str::random(40);
}
if (empty($clientSecret)) {
$clientSecret = Str::random(40);
}
$oAuthClient = OauthClient::create(array(
'id' => $clientId,
'secret' => $clientSecret,
'name' => $clientName
));
if ($oAuthClient->exists) {
$this->info('Client Name: '.$clientName);
$this->info('Client Id: '.$clientId);
$this->info('Client Secret: '.$clientSecret);
$this->info('Created');
} else {
$this->error('Client Name: '.$clientName);
$this->error('Failed');
}
} | php | public function fire()
{
$clientName = $this->argument('name');
$clientId = $this->option('id');
$clientSecret = $this->option('secret');
if (empty($clientId)) {
$clientId = Str::random(40);
}
if (empty($clientSecret)) {
$clientSecret = Str::random(40);
}
$oAuthClient = OauthClient::create(array(
'id' => $clientId,
'secret' => $clientSecret,
'name' => $clientName
));
if ($oAuthClient->exists) {
$this->info('Client Name: '.$clientName);
$this->info('Client Id: '.$clientId);
$this->info('Client Secret: '.$clientSecret);
$this->info('Created');
} else {
$this->error('Client Name: '.$clientName);
$this->error('Failed');
}
} | Execute the console command.
@return void | https://github.com/feelinc/laravel-api/blob/8b4abc4f1be255b441e09f5014e863a130c666d8/src/Sule/Api/Commands/NewOAuthClient.php#L51-L80 |
Dhii/map | src/AbstractBaseMap.php | AbstractBaseMap._throwIteratorException | protected function _throwIteratorException(
$message = null,
$code = null,
RootException $previous = null
) {
throw $this->_createIteratorException($message, $code, $previous, $this);
} | php | protected function _throwIteratorException(
$message = null,
$code = null,
RootException $previous = null
) {
throw $this->_createIteratorException($message, $code, $previous, $this);
} | {@inheritdoc}
@since [*next-version*] | https://github.com/Dhii/map/blob/9ec82af42b7cb33d3b0b70d753e8a2bc7451cedf/src/AbstractBaseMap.php#L233-L239 |
akumar2-velsof/guzzlehttp | src/Pool.php | Pool.batch | public static function batch(
ClientInterface $client,
$requests,
array $options = []
) {
$hash = new \SplObjectStorage();
foreach ($requests as $request) {
$hash->attach($request);
}
// In addition to the normally run events when requests complete, add
// and event to continuously track the results of transfers in the hash.
(new self($client, $requests, RequestEvents::convertEventArray(
$options,
['end'],
[
'priority' => RequestEvents::LATE,
'fn' => function (EndEvent $e) use ($hash) {
$hash[$e->getRequest()] = $e->getException()
? $e->getException()
: $e->getResponse();
}
]
)))->wait();
return new BatchResults($hash);
} | php | public static function batch(
ClientInterface $client,
$requests,
array $options = []
) {
$hash = new \SplObjectStorage();
foreach ($requests as $request) {
$hash->attach($request);
}
// In addition to the normally run events when requests complete, add
// and event to continuously track the results of transfers in the hash.
(new self($client, $requests, RequestEvents::convertEventArray(
$options,
['end'],
[
'priority' => RequestEvents::LATE,
'fn' => function (EndEvent $e) use ($hash) {
$hash[$e->getRequest()] = $e->getException()
? $e->getException()
: $e->getResponse();
}
]
)))->wait();
return new BatchResults($hash);
} | Sends multiple requests in parallel and returns an array of responses
and exceptions that uses the same ordering as the provided requests.
IMPORTANT: This method keeps every request and response in memory, and
as such, is NOT recommended when sending a large number or an
indeterminate number of requests concurrently.
@param ClientInterface $client Client used to send the requests
@param array|\Iterator $requests Requests to send in parallel
@param array $options Passes through the options available in
{@see GuzzleHttp1\Pool::__construct}
@return BatchResults Returns a container for the results.
@throws \InvalidArgumentException if the event format is incorrect. | https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/Pool.php#L109-L135 |
akumar2-velsof/guzzlehttp | src/Pool.php | Pool.send | public static function send(
ClientInterface $client,
$requests,
array $options = []
) {
$pool = new self($client, $requests, $options);
$pool->wait();
} | php | public static function send(
ClientInterface $client,
$requests,
array $options = []
) {
$pool = new self($client, $requests, $options);
$pool->wait();
} | Creates a Pool and immediately sends the requests.
@param ClientInterface $client Client used to send the requests
@param array|\Iterator $requests Requests to send in parallel
@param array $options Passes through the options available in
{@see GuzzleHttp1\Pool::__construct} | https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/Pool.php#L145-L152 |
akumar2-velsof/guzzlehttp | src/Pool.php | Pool.addNextRequests | private function addNextRequests()
{
$limit = max($this->getPoolSize() - count($this->waitQueue), 0);
while ($limit--) {
if (!$this->addNextRequest()) {
break;
}
}
} | php | private function addNextRequests()
{
$limit = max($this->getPoolSize() - count($this->waitQueue), 0);
while ($limit--) {
if (!$this->addNextRequest()) {
break;
}
}
} | Add as many requests as possible up to the current pool limit. | https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/Pool.php#L164-L172 |
akumar2-velsof/guzzlehttp | src/Pool.php | Pool.cancel | public function cancel()
{
if ($this->isRealized) {
return false;
}
$success = $this->isRealized = true;
foreach ($this->waitQueue as $response) {
if (!$response->cancel()) {
$success = false;
}
}
return $success;
} | php | public function cancel()
{
if ($this->isRealized) {
return false;
}
$success = $this->isRealized = true;
foreach ($this->waitQueue as $response) {
if (!$response->cancel()) {
$success = false;
}
}
return $success;
} | {@inheritdoc}
Attempt to cancel all outstanding requests (requests that are queued for
dereferencing). Returns true if all outstanding requests can be
cancelled.
@return bool | https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/Pool.php#L216-L230 |
akumar2-velsof/guzzlehttp | src/Pool.php | Pool.addNextRequest | private function addNextRequest()
{
add_next:
if ($this->isRealized || !$this->iter || !$this->iter->valid()) {
return false;
}
$request = $this->iter->current();
$this->iter->next();
if (!($request instanceof RequestInterface)) {
throw new \InvalidArgumentException(sprintf(
'All requests in the provided iterator must implement '
. 'RequestInterface. Found %s',
Core::describeType($request)
));
}
// Be sure to use "lazy" futures, meaning they do not send right away.
$request->getConfig()->set('future', 'lazy');
$hash = spl_object_hash($request);
$this->attachListeners($request, $this->eventListeners);
$request->getEmitter()->on('before', [$this, '_trackRetries'], RequestEvents::EARLY);
$response = $this->client->send($request);
$this->waitQueue[$hash] = $response;
$promise = $response->promise();
// Don't recursively call itself for completed or rejected responses.
if ($promise instanceof FulfilledPromise
|| $promise instanceof RejectedPromise
) {
try {
$this->finishResponse($request, $response->wait(), $hash);
} catch (\Exception $e) {
$this->finishResponse($request, $e, $hash);
}
goto add_next;
}
// Use this function for both resolution and rejection.
$thenFn = function ($value) use ($request, $hash) {
$this->finishResponse($request, $value, $hash);
if (!$request->getConfig()->get('_pool_retries')) {
$this->addNextRequests();
}
};
$promise->then($thenFn, $thenFn);
return true;
} | php | private function addNextRequest()
{
add_next:
if ($this->isRealized || !$this->iter || !$this->iter->valid()) {
return false;
}
$request = $this->iter->current();
$this->iter->next();
if (!($request instanceof RequestInterface)) {
throw new \InvalidArgumentException(sprintf(
'All requests in the provided iterator must implement '
. 'RequestInterface. Found %s',
Core::describeType($request)
));
}
// Be sure to use "lazy" futures, meaning they do not send right away.
$request->getConfig()->set('future', 'lazy');
$hash = spl_object_hash($request);
$this->attachListeners($request, $this->eventListeners);
$request->getEmitter()->on('before', [$this, '_trackRetries'], RequestEvents::EARLY);
$response = $this->client->send($request);
$this->waitQueue[$hash] = $response;
$promise = $response->promise();
// Don't recursively call itself for completed or rejected responses.
if ($promise instanceof FulfilledPromise
|| $promise instanceof RejectedPromise
) {
try {
$this->finishResponse($request, $response->wait(), $hash);
} catch (\Exception $e) {
$this->finishResponse($request, $e, $hash);
}
goto add_next;
}
// Use this function for both resolution and rejection.
$thenFn = function ($value) use ($request, $hash) {
$this->finishResponse($request, $value, $hash);
if (!$request->getConfig()->get('_pool_retries')) {
$this->addNextRequests();
}
};
$promise->then($thenFn, $thenFn);
return true;
} | Adds the next request to pool and tracks what requests need to be
dereferenced when completing the pool. | https://github.com/akumar2-velsof/guzzlehttp/blob/9588a489c52b27e2d4047f146ddacffc3e111b7e/src/Pool.php#L267-L318 |
ellipsephp/handlers-adr | src/ActionRequestHandler.php | ActionRequestHandler.handle | public function handle(ServerRequestInterface $request): ResponseInterface
{
$input = $this->input($request);
$payload = $this->domain->payload($input);
return $this->responder->response($request, $payload);
} | php | public function handle(ServerRequestInterface $request): ResponseInterface
{
$input = $this->input($request);
$payload = $this->domain->payload($input);
return $this->responder->response($request, $payload);
} | Return a response by following the action domain responder pattern.
@param \Psr\Http\Message\ServerRequestInterface $request
@return \Psr\Http\Message\ResponseInterface | https://github.com/ellipsephp/handlers-adr/blob/1c0879494a8b7718f7e157d0cd41b4c5ec19b5c5/src/ActionRequestHandler.php#L57-L64 |
ellipsephp/handlers-adr | src/ActionRequestHandler.php | ActionRequestHandler.input | private function input(ServerRequestInterface $request): array
{
if (! is_null($this->parser)) {
$input = ($this->parser)($request);
if (is_array($input)) {
return $input;
}
throw new InputTypeException($input);
}
return array_merge(
$request->getAttributes(),
$request->getQueryParams(),
$request->getParsedBody(),
$request->getUploadedFiles()
);
} | php | private function input(ServerRequestInterface $request): array
{
if (! is_null($this->parser)) {
$input = ($this->parser)($request);
if (is_array($input)) {
return $input;
}
throw new InputTypeException($input);
}
return array_merge(
$request->getAttributes(),
$request->getQueryParams(),
$request->getParsedBody(),
$request->getUploadedFiles()
);
} | Return an input array from the given request using the request parser.
@param \Psr\Http\Message\ServerRequestInterface $request
@return array
@throws \Ellipse\Handlers\Exceptions\InputTypeException | https://github.com/ellipsephp/handlers-adr/blob/1c0879494a8b7718f7e157d0cd41b4c5ec19b5c5/src/ActionRequestHandler.php#L73-L95 |
zhengb302/LumengPHP | src/LumengPHP/Http/Routing/DefaultRouter.php | DefaultRouter.extractPathInfo | private function extractPathInfo($requestUri) {
$questionMarkPos = strpos($requestUri, '?');
if ($questionMarkPos === false) {
return $requestUri;
}
return substr($requestUri, 0, $questionMarkPos);
} | php | private function extractPathInfo($requestUri) {
$questionMarkPos = strpos($requestUri, '?');
if ($questionMarkPos === false) {
return $requestUri;
}
return substr($requestUri, 0, $questionMarkPos);
} | 从RequestUri提取PathInfo<br />
如:
/foo/bar => /foo/bar
/foo/bar?id=10086 => /foo/bar
@param string $requestUri
@return string | https://github.com/zhengb302/LumengPHP/blob/77f41c32a5c6ba71c65956e5c4650707b6168c41/src/LumengPHP/Http/Routing/DefaultRouter.php#L49-L56 |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Helper/Languages.php | Radial_Core_Helper_Languages.getStores | public function getStores($langCode = null)
{
$stores = array();
foreach (Mage::app()->getWebsites() as $website) {
$stores = array_replace($stores, $this->getWebsiteStores($website, $langCode));
}
return $stores;
} | php | public function getStores($langCode = null)
{
$stores = array();
foreach (Mage::app()->getWebsites() as $website) {
$stores = array_replace($stores, $this->getWebsiteStores($website, $langCode));
}
return $stores;
} | Return an array of stores and attach a language code to them, Varien_Object style
@param string $langCode (optional) if passed, only stores using that langCode are returned.
@return array of Mage_Core_Model_Store, keyed by StoreId. Each store has a new magic getter 'getLanguageCode()' | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Helper/Languages.php#L61-L68 |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Helper/Languages.php | Radial_Core_Helper_Languages.getWebsiteStores | public function getWebsiteStores($website, $langCode = null)
{
$stores = array();
$config = Mage::helper('radial_core')->getConfigModel();
$website = Mage::app()->getWebsite($website);
foreach ($website->getGroups() as $group) {
foreach ($group->getStores() as $store) {
$storeId = $store->getStoreId();
$config->setStore($storeId);
if (!$langCode || ($langCode === $config->languageCode)) {
$store->setLanguageCode($config->languageCode);
$stores[$storeId] = $store;
}
}
}
return $stores;
} | php | public function getWebsiteStores($website, $langCode = null)
{
$stores = array();
$config = Mage::helper('radial_core')->getConfigModel();
$website = Mage::app()->getWebsite($website);
foreach ($website->getGroups() as $group) {
foreach ($group->getStores() as $store) {
$storeId = $store->getStoreId();
$config->setStore($storeId);
if (!$langCode || ($langCode === $config->languageCode)) {
$store->setLanguageCode($config->languageCode);
$stores[$storeId] = $store;
}
}
}
return $stores;
} | Return an array of stores for the given website and attach a language code to them, Varien_Object style
@param mixed $website the website to get stores from.
@param string $langCode (optional) if passed, only stores using that langCode are returned.
@return array of Mage_Core_Model_Store, keyed by StoreId. Each store has a new magic getter 'getLanguageCode()' | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Helper/Languages.php#L75-L91 |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Helper/Languages.php | Radial_Core_Helper_Languages.getLanguageCodesList | public function getLanguageCodesList()
{
$languages = array();
foreach ($this->getStores() as $store) {
$languages[] = $store->getLanguageCode();
}
return array_unique($languages);
} | php | public function getLanguageCodesList()
{
$languages = array();
foreach ($this->getStores() as $store) {
$languages[] = $store->getLanguageCode();
}
return array_unique($languages);
} | Get a simple array of all language codes used in this installation
@return array | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Helper/Languages.php#L96-L103 |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Helper/Languages.php | Radial_Core_Helper_Languages.validateLanguageCode | public function validateLanguageCode($languageCode)
{
// Swallow libxml warnings. In this tightly controlled case, all that
// can be expected to be invalid in the XML is the language code so
// the warnings won't tell us anything more useful anyway.
set_error_handler(function () {
});
// Need to capture results instead of just returning them so the error
// handler used to swallow the libxml errors can be removed.
$isValid = $this->_buildLanguageCheckDocument($languageCode)
->schemaValidate($this->_getLanguageCodeValidationSchemaFile());
restore_error_handler();
return $isValid;
} | php | public function validateLanguageCode($languageCode)
{
// Swallow libxml warnings. In this tightly controlled case, all that
// can be expected to be invalid in the XML is the language code so
// the warnings won't tell us anything more useful anyway.
set_error_handler(function () {
});
// Need to capture results instead of just returning them so the error
// handler used to swallow the libxml errors can be removed.
$isValid = $this->_buildLanguageCheckDocument($languageCode)
->schemaValidate($this->_getLanguageCodeValidationSchemaFile());
restore_error_handler();
return $isValid;
} | Check for the language code to be a valid xml:lang. Uses a simple xsd
and schema validation to ensure the value is valid. This will use the
same schema definitions for xml:lang attributes as those used in the
feed xsds, so any values that are valid in the feeds should also be
valid in this case.
@param string
@return bool | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Helper/Languages.php#L115-L128 |
RadialCorp/magento-core | src/app/code/community/Radial/Core/Helper/Languages.php | Radial_Core_Helper_Languages._getLanguageCodeValidationSchemaFile | protected function _getLanguageCodeValidationSchemaFile()
{
$cfg = $this->_coreHelper->getConfigModel();
return Mage::getBaseDir() . DS . $cfg->apiXsdPath . DS . self::LANGUAGE_CODE_SCHEMA;
} | php | protected function _getLanguageCodeValidationSchemaFile()
{
$cfg = $this->_coreHelper->getConfigModel();
return Mage::getBaseDir() . DS . $cfg->apiXsdPath . DS . self::LANGUAGE_CODE_SCHEMA;
} | Get the path to the XSD schema file to use to validate the DOMDocument
used to check an xml:lang.
@return string | https://github.com/RadialCorp/magento-core/blob/9bb5f218d9caf79eab8598f4f8447037a0cc6355/src/app/code/community/Radial/Core/Helper/Languages.php#L152-L156 |
Synapse-Cmf/synapse-cmf | src/Synapse/Cmf/Framework/Engine/Context/Component/RenderingContextBuilder.php | RenderingContextBuilder.createContext | public function createContext()
{
$resolvedOptions = $this->optionsResolver->resolve($this->options);
// wrap content
if ($resolvedOptions['content'] instanceof ContentInterface) {
$resolvedOptions['content'] = $this->contentResolver->resolve(
$resolvedOptions['content']
);
}
// create variation
$variation = $this->variationResolver->resolve((new VariationContext())
->denormalize($resolvedOptions)
);
return new RenderingContext(
$resolvedOptions['component'],
$resolvedOptions['content'],
$variation,
$this->contextNormalizer->normalize(
$resolvedOptions['content'],
$resolvedOptions['theme'],
$resolvedOptions['template'],
$resolvedOptions['zone'],
$resolvedOptions['component']
)
);
} | php | public function createContext()
{
$resolvedOptions = $this->optionsResolver->resolve($this->options);
// wrap content
if ($resolvedOptions['content'] instanceof ContentInterface) {
$resolvedOptions['content'] = $this->contentResolver->resolve(
$resolvedOptions['content']
);
}
// create variation
$variation = $this->variationResolver->resolve((new VariationContext())
->denormalize($resolvedOptions)
);
return new RenderingContext(
$resolvedOptions['component'],
$resolvedOptions['content'],
$variation,
$this->contextNormalizer->normalize(
$resolvedOptions['content'],
$resolvedOptions['theme'],
$resolvedOptions['template'],
$resolvedOptions['zone'],
$resolvedOptions['component']
)
);
} | Create context from defined members.
@return RenderingContext | https://github.com/Synapse-Cmf/synapse-cmf/blob/d8122a4150a83d5607289724425cf35c56a5e880/src/Synapse/Cmf/Framework/Engine/Context/Component/RenderingContextBuilder.php#L62-L90 |
Tuna-CMS/tuna-bundle | src/Tuna/Bundle/GalleryBundle/Entity/GalleryItem.php | GalleryItem.setType | public function setType($type)
{
if (!in_array($type, self::$TYPES)) {
throw new \InvalidArgumentException(sprintf(
"Unknown GalleryItem type (given: '%s', available: '%s')",
$type,
implode(', ', self::$TYPES)
));
}
$this->type = $type;
return $this;
} | php | public function setType($type)
{
if (!in_array($type, self::$TYPES)) {
throw new \InvalidArgumentException(sprintf(
"Unknown GalleryItem type (given: '%s', available: '%s')",
$type,
implode(', ', self::$TYPES)
));
}
$this->type = $type;
return $this;
} | Set type
@param string $type
@return GalleryItem | https://github.com/Tuna-CMS/tuna-bundle/blob/1f999de44e14cbe9f992d46f2e5e74ddc117b04c/src/Tuna/Bundle/GalleryBundle/Entity/GalleryItem.php#L206-L218 |
chilimatic/chilimatic-framework | lib/route/Validator.php | Validator.getMatches | private function getMatches()
{
if (empty($this->urlPart) || !$this->validate($this->urlPart)) {
return [];
}
if (!preg_match($this->_current_pattern, $this->urlPart, $matches)) {
return [];
}
return $matches;
} | php | private function getMatches()
{
if (empty($this->urlPart) || !$this->validate($this->urlPart)) {
return [];
}
if (!preg_match($this->_current_pattern, $this->urlPart, $matches)) {
return [];
}
return $matches;
} | extract pattern
@return array | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/route/Validator.php#L96-L108 |
chilimatic/chilimatic-framework | lib/route/Validator.php | Validator.init | public function init($urlPart = null)
{
try {
if (!empty($urlPart) && $this->validate($urlPart)) {
$this->urlPart = $urlPart;
}
if (empty($this->urlPart) || !$this->validate($this->urlPart)) {
throw new RouteException('url part empty or not a valid pattern : ' . $this->urlPart);
}
$array = $this->getMatches();
$validator = (string)(get_class($this) . '\\') . self::VALIDATORPREFIX . ucfirst($array[1]);
if (!class_exists($validator)) {
throw new RouteException('Class does not exist : ' . $validator);
}
} catch (RouteException $e) {
throw $e;
}
$this->validator = new $validator();
if (isset($array[2])) {
$this->validator->delimiter = $array[2];
}
return $this;
} | php | public function init($urlPart = null)
{
try {
if (!empty($urlPart) && $this->validate($urlPart)) {
$this->urlPart = $urlPart;
}
if (empty($this->urlPart) || !$this->validate($this->urlPart)) {
throw new RouteException('url part empty or not a valid pattern : ' . $this->urlPart);
}
$array = $this->getMatches();
$validator = (string)(get_class($this) . '\\') . self::VALIDATORPREFIX . ucfirst($array[1]);
if (!class_exists($validator)) {
throw new RouteException('Class does not exist : ' . $validator);
}
} catch (RouteException $e) {
throw $e;
}
$this->validator = new $validator();
if (isset($array[2])) {
$this->validator->delimiter = $array[2];
}
return $this;
} | init method
@param null $urlPart
@internal param string $url_part
@return $this | https://github.com/chilimatic/chilimatic-framework/blob/8df7f12e75d75d3fd2197a58c80d39cbb4b9ff12/lib/route/Validator.php#L120-L149 |
smartboxgroup/camel-config-bundle | DependencyInjection/Configuration.php | Configuration.getConfigTreeBuilder | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('smartbox_integration_camel_config');
$rootNode
->children()
->arrayNode('flows_directories')
->prototype('scalar')
->validate()
->ifTrue(
function ($folder) {
return !file_exists($folder) || !is_dir($folder);
}
)
->thenInvalid('"%s" is not an existent directory.')
->end()
->end()
->end()
->scalarNode('frozen_flows_directory')->isRequired()->cannotBeEmpty()
->end()
->end()
->end();
return $treeBuilder;
} | php | public function getConfigTreeBuilder()
{
$treeBuilder = new TreeBuilder();
$rootNode = $treeBuilder->root('smartbox_integration_camel_config');
$rootNode
->children()
->arrayNode('flows_directories')
->prototype('scalar')
->validate()
->ifTrue(
function ($folder) {
return !file_exists($folder) || !is_dir($folder);
}
)
->thenInvalid('"%s" is not an existent directory.')
->end()
->end()
->end()
->scalarNode('frozen_flows_directory')->isRequired()->cannotBeEmpty()
->end()
->end()
->end();
return $treeBuilder;
} | {@inheritdoc} | https://github.com/smartboxgroup/camel-config-bundle/blob/f38505c50a446707b8e8f79ecaa1addd0a6cca11/DependencyInjection/Configuration.php#L18-L42 |
Opifer/RedirectBundle | Form/Type/RedirectType.php | RedirectType.buildForm | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('origin', TextType::class, [
'label' =>'opifer_redirect.form.origin.label',
'attr' => [
'help_text' => 'opifer_redirect.form.origin.help_text',
]
])
->add('target', TextType::class, [
'label' =>'opifer_redirect.form.target.label',
'attr' => [
'help_text' => 'opifer_redirect.form.target.help_text',
]
])
->add('permanent', CheckboxType::class, [
'attr' => [
'align_with_widget' => true,
]
])
->add('requirements', CollectionType::class, [
'type' => RequirementType::class,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'label' =>'opifer_redirect.form.requirements.label',
'attr' => [
'help_text' => 'opifer_redirect.form.requirements.help_text',
]
])
;
} | php | public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('origin', TextType::class, [
'label' =>'opifer_redirect.form.origin.label',
'attr' => [
'help_text' => 'opifer_redirect.form.origin.help_text',
]
])
->add('target', TextType::class, [
'label' =>'opifer_redirect.form.target.label',
'attr' => [
'help_text' => 'opifer_redirect.form.target.help_text',
]
])
->add('permanent', CheckboxType::class, [
'attr' => [
'align_with_widget' => true,
]
])
->add('requirements', CollectionType::class, [
'type' => RequirementType::class,
'allow_add' => true,
'allow_delete' => true,
'by_reference' => false,
'label' =>'opifer_redirect.form.requirements.label',
'attr' => [
'help_text' => 'opifer_redirect.form.requirements.help_text',
]
])
;
} | {@inheritDoc} | https://github.com/Opifer/RedirectBundle/blob/b2668949a17e6acae34c3c59e5f2973c91cfc6a7/Form/Type/RedirectType.php#L16-L47 |
rkeet/zf-doctrine-mvc | src/Controller/AbstractActionController.php | AbstractActionController.redirectToRoute | public function redirectToRoute()
{
if ($this->getRequest()
->isXmlHttpRequest()) {
return [
'redirect' => call_user_func_array(
[
$this->url(),
'fromRoute',
],
func_get_args()
),
];
}
return call_user_func_array(
[
$this->redirect(),
'toRoute',
],
func_get_args()
);
} | php | public function redirectToRoute()
{
if ($this->getRequest()
->isXmlHttpRequest()) {
return [
'redirect' => call_user_func_array(
[
$this->url(),
'fromRoute',
],
func_get_args()
),
];
}
return call_user_func_array(
[
$this->redirect(),
'toRoute',
],
func_get_args()
);
} | Redirect to a route, or pass the url to the view for a javascript redirect
@return mixed|\Zend\Http\Response | https://github.com/rkeet/zf-doctrine-mvc/blob/ec5fb19e453824383b39570d15bd77b85cec3ca1/src/Controller/AbstractActionController.php#L14-L36 |
rkeet/zf-doctrine-mvc | src/Controller/AbstractActionController.php | AbstractActionController.givenClassAndParentTraits | protected function givenClassAndParentTraits($class, $autoload = true)
{
$traits = [];
// Get traits of all parent classes
while ($class = get_parent_class($class)) {
$traits = array_merge(class_uses($class, $autoload), $traits);
};
// Get traits of all parent traits
$traitsToSearch = $traits;
while ( ! empty($traitsToSearch)) {
$newTraits = class_uses(array_pop($traitsToSearch), $autoload);
$traits = array_merge($newTraits, $traits);
$traitsToSearch = array_merge($newTraits, $traitsToSearch);
};
foreach ($traits as $trait => $same) {
$traits = array_merge(class_uses($trait, $autoload), $traits);
}
return array_unique($traits);
} | php | protected function givenClassAndParentTraits($class, $autoload = true)
{
$traits = [];
// Get traits of all parent classes
while ($class = get_parent_class($class)) {
$traits = array_merge(class_uses($class, $autoload), $traits);
};
// Get traits of all parent traits
$traitsToSearch = $traits;
while ( ! empty($traitsToSearch)) {
$newTraits = class_uses(array_pop($traitsToSearch), $autoload);
$traits = array_merge($newTraits, $traits);
$traitsToSearch = array_merge($newTraits, $traitsToSearch);
};
foreach ($traits as $trait => $same) {
$traits = array_merge(class_uses($trait, $autoload), $traits);
}
return array_unique($traits);
} | Gets all Trait's used by class and parent classes, see comments @link http://php.net/class_uses
@param $class
@param bool $autoload
@return array | https://github.com/rkeet/zf-doctrine-mvc/blob/ec5fb19e453824383b39570d15bd77b85cec3ca1/src/Controller/AbstractActionController.php#L46-L68 |
intaro/hstore-bundle | DependencyInjection/IntaroHStoreExtension.php | IntaroHStoreExtension.prepend | public function prepend(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);
$dbalConfig = [
'dbal' => [
'types' => [
'hstore' => 'Intaro\HStoreBundle\DBAL\Types\HStoreType'
],
'mapping_types' => [
'hstore' => 'hstore'
],
],
'orm' => [
'dql' => [
'string_functions' => [
'contains' => 'Intaro\HStoreBundle\DQL\ContainsFunction',
'defined' => 'Intaro\HStoreBundle\DQL\DefinedFunction',
'existsAny' => 'Intaro\HStoreBundle\DQL\ExistsAnyFunction',
'hstoreDifference' => 'Intaro\HStoreBundle\DQL\HstoreDifferenceFunction',
'fetchval' => 'Intaro\HStoreBundle\DQL\FetchvalFunction'
]
]
]
];
$container->prependExtensionConfig('doctrine', $dbalConfig);
} | php | public function prepend(ContainerBuilder $container)
{
$configs = $container->getExtensionConfig($this->getAlias());
$config = $this->processConfiguration(new Configuration(), $configs);
$dbalConfig = [
'dbal' => [
'types' => [
'hstore' => 'Intaro\HStoreBundle\DBAL\Types\HStoreType'
],
'mapping_types' => [
'hstore' => 'hstore'
],
],
'orm' => [
'dql' => [
'string_functions' => [
'contains' => 'Intaro\HStoreBundle\DQL\ContainsFunction',
'defined' => 'Intaro\HStoreBundle\DQL\DefinedFunction',
'existsAny' => 'Intaro\HStoreBundle\DQL\ExistsAnyFunction',
'hstoreDifference' => 'Intaro\HStoreBundle\DQL\HstoreDifferenceFunction',
'fetchval' => 'Intaro\HStoreBundle\DQL\FetchvalFunction'
]
]
]
];
$container->prependExtensionConfig('doctrine', $dbalConfig);
} | {@inheritDoc} | https://github.com/intaro/hstore-bundle/blob/7ed7c3ec9e4089d4ab430c179ea090502ccd6730/DependencyInjection/IntaroHStoreExtension.php#L21-L49 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.cookie | public function cookie(string $index = '', $xss_clean = false)
{
return $this->fetchFromArray($_COOKIE, $index, $xss_clean);
} | php | public function cookie(string $index = '', $xss_clean = false)
{
return $this->fetchFromArray($_COOKIE, $index, $xss_clean);
} | Grab values from the $_COOKIE global.
@param mixed $index The index that we will be searching for.
@param boolean $xss_clean Whether we want to clean it or not.
@since 1.0.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L45-L48 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.fetchFromArray | protected function fetchFromArray(
array $array,
string $index = '',
$xss_clean = false
) {
if (!array_key_exists($index, $array)) {
return false;
}
// Checks to see if the variable is set, since 0 returns as false.
if ($xss_clean === 'isset') {
return array_key_exists($index, $array);
}
return $array[$index];
} | php | protected function fetchFromArray(
array $array,
string $index = '',
$xss_clean = false
) {
if (!array_key_exists($index, $array)) {
return false;
}
// Checks to see if the variable is set, since 0 returns as false.
if ($xss_clean === 'isset') {
return array_key_exists($index, $array);
}
return $array[$index];
} | The function that will handle getting the data from the arrays.
@param mixed $array The array that will pulled from.
@param string $index What we are looking for.
@param boolean $xss_clean Whether to clean it or not or not. Incomplete.
@since 1.0.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L60-L75 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.get | public function get(?string $index = null, $xss_clean = false)
{
if ($index === null && \count($_GET) > 0) {
$get = [];
// Loop through the full $_GET array.
foreach (array_keys($_GET) as $key) {
$get[$key] = $this->fetchFromArray($_GET, $key, $xss_clean);
}
return $get;
}
return $this->fetchFromArray($_GET, $index, $xss_clean);
} | php | public function get(?string $index = null, $xss_clean = false)
{
if ($index === null && \count($_GET) > 0) {
$get = [];
// Loop through the full $_GET array.
foreach (array_keys($_GET) as $key) {
$get[$key] = $this->fetchFromArray($_GET, $key, $xss_clean);
}
return $get;
}
return $this->fetchFromArray($_GET, $index, $xss_clean);
} | Grab values from the $_GET global.
@param mixed $index The index that we will be searching for.
@param boolean $xss_clean Whether we want to clean it or not.
@since 1.0.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L86-L100 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.request | public function request(?string $index = null, $xss_clean = false)
{
// Check if a field has been provided.
if ($index === null && \count($_REQUEST) > 0) {
$request = [];
// Loop through the full $_REQUEST array and return the value.
foreach (array_keys($_REQUEST) as $key) {
$request[$key] = $this->fetchFromArray($_REQUEST, $key, $xss_clean);
}
return $request;
}
return $this->fetchFromArray($_REQUEST, $index, $xss_clean);
} | php | public function request(?string $index = null, $xss_clean = false)
{
// Check if a field has been provided.
if ($index === null && \count($_REQUEST) > 0) {
$request = [];
// Loop through the full $_REQUEST array and return the value.
foreach (array_keys($_REQUEST) as $key) {
$request[$key] = $this->fetchFromArray($_REQUEST, $key, $xss_clean);
}
return $request;
}
return $this->fetchFromArray($_REQUEST, $index, $xss_clean);
} | Grab values from the $_REQUEST global.
@param mixed $index The index that we will be searching for.
@param boolean $xss_clean Whether we want to clean it or not.
@since 1.5.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L111-L126 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.post | public function post(?string $index = null, $xss_clean = false)
{
// Check if a field has been provided.
if ($index === null && \count($_POST) > 0) {
$post = [];
// Loop through the full $_POST array and return the value.
foreach (array_keys($_POST) as $key) {
$post[$key] = $this->fetchFromArray($_POST, $key, $xss_clean);
}
return $post;
}
return $this->fetchFromArray($_POST, $index, $xss_clean);
} | php | public function post(?string $index = null, $xss_clean = false)
{
// Check if a field has been provided.
if ($index === null && \count($_POST) > 0) {
$post = [];
// Loop through the full $_POST array and return the value.
foreach (array_keys($_POST) as $key) {
$post[$key] = $this->fetchFromArray($_POST, $key, $xss_clean);
}
return $post;
}
return $this->fetchFromArray($_POST, $index, $xss_clean);
} | Grab values from the $_POST global.
@param mixed $index The index that we will be searching for.
@param boolean $xss_clean Whether we want to clean it or not.
@since 1.0.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L137-L152 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.server | public function server(string $index = '', $xss_clean = false)
{
return $this->fetchFromArray($_SERVER, $index, $xss_clean);
} | php | public function server(string $index = '', $xss_clean = false)
{
return $this->fetchFromArray($_SERVER, $index, $xss_clean);
} | Grab values from the $_SERVER global.
@param mixed $index The index that we will be searching for.
@param boolean $xss_clean Whether we want to clean it or not.
@since 1.0.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L163-L166 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.session | public function session(string $index = '', $xss_clean = false)
{
return $this->fetchFromArray($_SESSION, $index, $xss_clean);
} | php | public function session(string $index = '', $xss_clean = false)
{
return $this->fetchFromArray($_SESSION, $index, $xss_clean);
} | Grab values from the $_SESSION global.
@param mixed $index The index that we will be searching for.
@param boolean $xss_clean Whether we want to clean it or not.
@since 1.0.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L177-L180 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.setSession | public function setSession(string $index = '', $value = '')
{
if (array_key_exists($index, $_SESSION))
{
return false;
}
$_SESSION[$index] = $value;
return true;
} | php | public function setSession(string $index = '', $value = '')
{
if (array_key_exists($index, $_SESSION))
{
return false;
}
$_SESSION[$index] = $value;
return true;
} | Set values in the $_SESSION global.
@param mixed $index The index that we will be setting.
@param mixed $value Value of what we will be setting in the index.
@since 1.0.0
@return mixed | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L191-L201 |
dark-prospect-games/obsidian-moon-engine | src/Modules/Input.php | Input.unsetSession | public function unsetSession(string $index = ''): bool
{
unset($_SESSION[$index]);
if (!array_key_exists($index, $_SESSION))
{
return true;
}
return false;
} | php | public function unsetSession(string $index = ''): bool
{
unset($_SESSION[$index]);
if (!array_key_exists($index, $_SESSION))
{
return true;
}
return false;
} | Remove values from the $_SESSION global.
@param mixed $index The index that we will be removing.
@since 1.0.0
@return boolean | https://github.com/dark-prospect-games/obsidian-moon-engine/blob/83b82990bdea79960a93b52f963cc81b6fa009ba/src/Modules/Input.php#L211-L220 |
acacha/forge-publish | src/Console/Commands/PublishKeyGenerate.php | PublishKeyGenerate.keyIsAlreadyInstalled | protected function keyIsAlreadyInstalled()
{
$key = 'APP_KEY=base64:';
$output = $this->execSSH("cd $this->domain;cat .env");
if (str_contains($output, $key)) {
return true;
}
return false;
} | php | protected function keyIsAlreadyInstalled()
{
$key = 'APP_KEY=base64:';
$output = $this->execSSH("cd $this->domain;cat .env");
if (str_contains($output, $key)) {
return true;
}
return false;
} | Key is already installed on production?
@return bool | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishKeyGenerate.php#L88-L96 |
acacha/forge-publish | src/Console/Commands/PublishKeyGenerate.php | PublishKeyGenerate.abortCommandExecution | protected function abortCommandExecution()
{
$this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
$this->domain = $this->checkEnv('domain', 'ACACHA_FORGE_DOMAIN');
$this->abortIfNoSSHConnection();
} | php | protected function abortCommandExecution()
{
$this->server = $this->checkEnv('server', 'ACACHA_FORGE_SERVER');
$this->domain = $this->checkEnv('domain', 'ACACHA_FORGE_DOMAIN');
$this->abortIfNoSSHConnection();
} | Abort command execution? | https://github.com/acacha/forge-publish/blob/010779e3d2297c763b82dc3fbde992edffb3a6c6/src/Console/Commands/PublishKeyGenerate.php#L101-L107 |
luoxiaojun1992/lb_framework | Lb.php | Lb.app | public static function app()
{
if (static::$app instanceof self) {
return static::$app;
} else {
$app = new static(true);
$app->is_single = true;
return (static::$app = $app);
}
} | php | public static function app()
{
if (static::$app instanceof self) {
return static::$app;
} else {
$app = new static(true);
$app->is_single = true;
return (static::$app = $app);
}
} | Singleton App
@return static | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L77-L86 |
luoxiaojun1992/lb_framework | Lb.php | Lb.getRouteInfo | public function getRouteInfo()
{
if ($this->isSingle()) {
if (isset($this->containers['route_info']) && ($controller = $this->containers['route_info']->get('controller'))
&& ($action = $this->containers['route_info']->get('action'))
) {
return ['controller' => $controller, 'action' => $action];
}
}
return ['controller' => 'index', 'action' => 'index'];
} | php | public function getRouteInfo()
{
if ($this->isSingle()) {
if (isset($this->containers['route_info']) && ($controller = $this->containers['route_info']->get('controller'))
&& ($action = $this->containers['route_info']->get('action'))
) {
return ['controller' => $controller, 'action' => $action];
}
}
return ['controller' => 'index', 'action' => 'index'];
} | Get Route Info
@return array | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L197-L207 |
luoxiaojun1992/lb_framework | Lb.php | Lb.isHome | public function isHome()
{
if ($this->isSingle()) {
if (isset($this->containers['route_info'])) {
$home_controller = 'index';
$home_action = 'index';
$home = $this->getHome();
if ($home && isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$home_controller = $home['controller'];
$home_action = $home['action'];
}
if ($this->containers['route_info']->get('controller') == $home_controller && $this->containers['route_info']->get('action') == $home_action) {
return true;
}
}
}
return false;
} | php | public function isHome()
{
if ($this->isSingle()) {
if (isset($this->containers['route_info'])) {
$home_controller = 'index';
$home_action = 'index';
$home = $this->getHome();
if ($home && isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$home_controller = $home['controller'];
$home_action = $home['action'];
}
if ($this->containers['route_info']->get('controller') == $home_controller && $this->containers['route_info']->get('action') == $home_action) {
return true;
}
}
}
return false;
} | If is home | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L210-L227 |
luoxiaojun1992/lb_framework | Lb.php | Lb.getHomeUri | public function getHomeUri()
{
$homeUri = '';
if ($this->isSingle()) {
$controller = 'index';
$action = 'index';
$home = $this->getHome();
if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$controller = $home['controller'];
$action = $home['action'];
}
if ($this->isPrettyUrl()) {
$homeUri = $this->createRelativeUrl("/{$controller}/action/{$action}");
} else {
$homeUri = $this->createRelativeUrl('/index.php', [$controller, 'action' => $action]);
}
}
return $homeUri;
} | php | public function getHomeUri()
{
$homeUri = '';
if ($this->isSingle()) {
$controller = 'index';
$action = 'index';
$home = $this->getHome();
if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$controller = $home['controller'];
$action = $home['action'];
}
if ($this->isPrettyUrl()) {
$homeUri = $this->createRelativeUrl("/{$controller}/action/{$action}");
} else {
$homeUri = $this->createRelativeUrl('/index.php', [$controller, 'action' => $action]);
}
}
return $homeUri;
} | Get Home Uri | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L230-L248 |
luoxiaojun1992/lb_framework | Lb.php | Lb.goHome | public function goHome()
{
if ($this->isSingle()) {
$controller = 'index';
$action = 'index';
$home = $this->getHome();
if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$controller = $home['controller'];
$action = $home['action'];
}
if ($this->isPrettyUrl()) {
$home_url = $this->createRelativeUrl("/{$controller}/action/{$action}");
} else {
$home_url = $this->createRelativeUrl("/index.php?{$controller}&action={$action}");
}
$this->redirect($home_url);
}
} | php | public function goHome()
{
if ($this->isSingle()) {
$controller = 'index';
$action = 'index';
$home = $this->getHome();
if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$controller = $home['controller'];
$action = $home['action'];
}
if ($this->isPrettyUrl()) {
$home_url = $this->createRelativeUrl("/{$controller}/action/{$action}");
} else {
$home_url = $this->createRelativeUrl("/index.php?{$controller}&action={$action}");
}
$this->redirect($home_url);
}
} | Go Home | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L251-L268 |
luoxiaojun1992/lb_framework | Lb.php | Lb.goBack | public function goBack()
{
if ($this->isSingle()) {
$referer = $this->getReferer();
if ($referer) {
$this->redirect($referer);
}
}
} | php | public function goBack()
{
if ($this->isSingle()) {
$referer = $this->getReferer();
if ($referer) {
$this->redirect($referer);
}
}
} | Go Back | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L271-L279 |
luoxiaojun1992/lb_framework | Lb.php | Lb.getDb | public function getDb($db_type, $node_type)
{
if ($this->isSingle()) {
switch ($db_type) {
case Connection::DB_TYPE:
switch ($node_type) {
case 'master':
return Connection::component()->write_conn;
case 'slave':
return Connection::component()->read_conn;
default:
return Connection::component()->write_conn;
}
case \lb\components\db\mongodb\Connection::DB_TYPE :
return \lb\components\db\mongodb\Connection::component()->_conn;
default:
return false;
}
}
return false;
} | php | public function getDb($db_type, $node_type)
{
if ($this->isSingle()) {
switch ($db_type) {
case Connection::DB_TYPE:
switch ($node_type) {
case 'master':
return Connection::component()->write_conn;
case 'slave':
return Connection::component()->read_conn;
default:
return Connection::component()->write_conn;
}
case \lb\components\db\mongodb\Connection::DB_TYPE :
return \lb\components\db\mongodb\Connection::component()->_conn;
default:
return false;
}
}
return false;
} | Get Db Connection | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L282-L302 |
luoxiaojun1992/lb_framework | Lb.php | Lb.redirect | public function redirect($path, $replace = true, $http_response_code = null, $response = null)
{
if ($this->isSingle()) {
UrlManager::redirect($path, $replace, $http_response_code, $response);
}
} | php | public function redirect($path, $replace = true, $http_response_code = null, $response = null)
{
if ($this->isSingle()) {
UrlManager::redirect($path, $replace, $http_response_code, $response);
}
} | Request Redirect | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L305-L310 |
luoxiaojun1992/lb_framework | Lb.php | Lb.createAbsoluteUrl | public function createAbsoluteUrl($uri, $query_params = [], $ssl = false, $port = 80, $request = null)
{
if ($this->isSingle()) {
return UrlManager::createAbsoluteUrl($uri, $query_params, $ssl, $port, $request);
}
return '';
} | php | public function createAbsoluteUrl($uri, $query_params = [], $ssl = false, $port = 80, $request = null)
{
if ($this->isSingle()) {
return UrlManager::createAbsoluteUrl($uri, $query_params, $ssl, $port, $request);
}
return '';
} | Create Absolute Url | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L313-L319 |
luoxiaojun1992/lb_framework | Lb.php | Lb.getParam | public function getParam($param_name, $default_value = null)
{
if ($this->isSingle()) {
return RequestKit::getParam($param_name, $default_value);
}
return false;
} | php | public function getParam($param_name, $default_value = null)
{
if ($this->isSingle()) {
return RequestKit::getParam($param_name, $default_value);
}
return false;
} | Get Http Request Param Value | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L331-L337 |
luoxiaojun1992/lb_framework | Lb.php | Lb.import | public function import($path)
{
if ($this->isSingle()) {
if (file_exists($path) && strtolower(FileHelper::getExtensionName($path)) == 'php') {
include_once str_replace(Security::INSECURE_CODES, '', $path);
}
}
} | php | public function import($path)
{
if ($this->isSingle()) {
if (file_exists($path) && strtolower(FileHelper::getExtensionName($path)) == 'php') {
include_once str_replace(Security::INSECURE_CODES, '', $path);
}
}
} | Import PHP File | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L367-L374 |
luoxiaojun1992/lb_framework | Lb.php | Lb.swiftSend | public function swiftSend(
$from_name,
$receivers,
&$successfulRecipients,
&$failedRecipients,
$subject = '',
$body = '',
$content_type = 'text/html',
$charset = 'UTF-8'
) {
if ($this->isSingle()) {
Swift::component()->send(
$from_name,
$receivers,
$successfulRecipients,
$failedRecipients,
$subject,
$body,
$content_type,
$charset
);
}
} | php | public function swiftSend(
$from_name,
$receivers,
&$successfulRecipients,
&$failedRecipients,
$subject = '',
$body = '',
$content_type = 'text/html',
$charset = 'UTF-8'
) {
if ($this->isSingle()) {
Swift::component()->send(
$from_name,
$receivers,
$successfulRecipients,
$failedRecipients,
$subject,
$body,
$content_type,
$charset
);
}
} | Send Swift Mail | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L386-L409 |
luoxiaojun1992/lb_framework | Lb.php | Lb.loginRequired | public function loginRequired($redirect_url, $request = null, $response = null)
{
if ($this->isSingle()) {
User::loginRequired($redirect_url, $request, $response);
}
} | php | public function loginRequired($redirect_url, $request = null, $response = null)
{
if ($this->isSingle()) {
User::loginRequired($redirect_url, $request, $response);
}
} | Check If Logged In
@param $redirect_url
@param RequestContract $request
@param ResponseContract $response | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L418-L423 |
luoxiaojun1992/lb_framework | Lb.php | Lb.login | public function login($username, $user_id, $remember_token = '', $timeout = 0)
{
if ($this->isSingle()) {
User::login($username, $user_id, $remember_token, $timeout);
}
} | php | public function login($username, $user_id, $remember_token = '', $timeout = 0)
{
if ($this->isSingle()) {
User::login($username, $user_id, $remember_token, $timeout);
}
} | Log In | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L457-L462 |
luoxiaojun1992/lb_framework | Lb.php | Lb.isAction | public function isAction($request = null)
{
$is_action = false;
if ($this->isSingle()) {
$queryString = $request ? $request->getQueryString() : Lb::app()->getQueryString();
$requestUri = $request ? $request->getUri() : Lb::app()->getUri();
if (Lb::app()->isPrettyUrl()) {
$requestUri = str_replace('?' . $queryString, '', $requestUri);
if (!trim($requestUri, '/') || stripos($requestUri, '/action/') !== false) {
$is_action = true;
}
} else {
if (!trim($requestUri, '/') || stripos($queryString, 'action=') !== false) {
$is_action = true;
}
}
}
return $is_action;
} | php | public function isAction($request = null)
{
$is_action = false;
if ($this->isSingle()) {
$queryString = $request ? $request->getQueryString() : Lb::app()->getQueryString();
$requestUri = $request ? $request->getUri() : Lb::app()->getUri();
if (Lb::app()->isPrettyUrl()) {
$requestUri = str_replace('?' . $queryString, '', $requestUri);
if (!trim($requestUri, '/') || stripos($requestUri, '/action/') !== false) {
$is_action = true;
}
} else {
if (!trim($requestUri, '/') || stripos($queryString, 'action=') !== false) {
$is_action = true;
}
}
}
return $is_action;
} | Detect Action Exists
@param RequestContract $request
@return bool | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L478-L496 |
luoxiaojun1992/lb_framework | Lb.php | Lb.getPagination | public function getPagination($total, $page_size, $page = 1)
{
if ($this->isSingle()) {
return Pagination::getParams($total, $page_size, $page);
}
return [];
} | php | public function getPagination($total, $page_size, $page = 1)
{
if ($this->isSingle()) {
return Pagination::getParams($total, $page_size, $page);
}
return [];
} | Get Pagination | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L528-L534 |
luoxiaojun1992/lb_framework | Lb.php | Lb.isAjax | public function isAjax($request = null)
{
if ($this->isSingle()) {
return $request ? $request->isAjax() : RequestKit::isAjax();
}
return false;
} | php | public function isAjax($request = null)
{
if ($this->isSingle()) {
return $request ? $request->isAjax() : RequestKit::isAjax();
}
return false;
} | Is Ajax
@param RequestContract $request
@return bool | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L542-L548 |
luoxiaojun1992/lb_framework | Lb.php | Lb.get_rpc_client | public function get_rpc_client($url)
{
if ($this->isSingle()) {
include_once Lb::app()->getRootDir() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'hprose' .
DIRECTORY_SEPARATOR . 'hprose' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Hprose.php';
return new \Hprose\Http\Client($url);
}
return false;
} | php | public function get_rpc_client($url)
{
if ($this->isSingle()) {
include_once Lb::app()->getRootDir() . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'hprose' .
DIRECTORY_SEPARATOR . 'hprose' . DIRECTORY_SEPARATOR . 'src' . DIRECTORY_SEPARATOR . 'Hprose.php';
return new \Hprose\Http\Client($url);
}
return false;
} | Get RPC Client | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L551-L559 |
luoxiaojun1992/lb_framework | Lb.php | Lb.on | public function on($event_name, $listener, $data = null)
{
if ($this->isSingle()) {
BaseObserver::on($event_name, $listener, $data);
}
} | php | public function on($event_name, $listener, $data = null)
{
if ($this->isSingle()) {
BaseObserver::on($event_name, $listener, $data);
}
} | Register Event Listener | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L571-L576 |
luoxiaojun1992/lb_framework | Lb.php | Lb.trigger | public function trigger($event_name, $event = null, $ignoreQueue = false)
{
if ($this->isSingle()) {
BaseObserver::trigger($event_name, $event, $ignoreQueue);
}
} | php | public function trigger($event_name, $event = null, $ignoreQueue = false)
{
if ($this->isSingle()) {
BaseObserver::trigger($event_name, $event, $ignoreQueue);
}
} | Trigger Event | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L579-L584 |
luoxiaojun1992/lb_framework | Lb.php | Lb.dispatchJob | public function dispatchJob($job, $data = [], $handler = 'handler')
{
if ($this->isSingle()) {
if (!is_object($job)) {
$job = new $job;
}
return call_user_func_array([$job, $handler], ['data' => $data]);
}
return null;
} | php | public function dispatchJob($job, $data = [], $handler = 'handler')
{
if ($this->isSingle()) {
if (!is_object($job)) {
$job = new $job;
}
return call_user_func_array([$job, $handler], ['data' => $data]);
}
return null;
} | Dispatch a job
@param $job
@param array $data
@param string $handler
@return mixed | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L609-L619 |
luoxiaojun1992/lb_framework | Lb.php | Lb.autoload | protected static function autoload($className)
{
$root_dir = Lb::app()->getRootDir();
if ($root_dir) {
$className = str_replace('..', '', $className);
// Auto Load Controllers
if (strpos($className, 'app\controllers\\') === 0) {
$controllers_dir = $root_dir . DIRECTORY_SEPARATOR . 'controllers';
if (is_dir($controllers_dir)) {
$class_file_path = $controllers_dir . DIRECTORY_SEPARATOR . str_replace('app\controllers\\', '', $className) . 'Controller.php';
Lb::app()->import(str_replace('\\', DIRECTORY_SEPARATOR, $class_file_path));
}
}
// Auto Load Models
if (strpos($className, 'app\models\\') === 0) {
$models_dir = $root_dir . DIRECTORY_SEPARATOR . 'models';
if (is_dir($models_dir)) {
$class_file_path = $models_dir . DIRECTORY_SEPARATOR . str_replace('app\models\\', '', $className) . '.php';
Lb::app()->import(str_replace('\\', DIRECTORY_SEPARATOR, $class_file_path));
}
}
// Auto Load Components
if (strpos($className, 'app\components\\') === 0) {
$components_dir = $root_dir . DIRECTORY_SEPARATOR . 'components';
if (is_dir($components_dir)) {
$class_file_path = $components_dir . DIRECTORY_SEPARATOR . str_replace('app\components\\', '', $className) . '.php';
Lb::app()->import(str_replace('\\', DIRECTORY_SEPARATOR, $class_file_path));
}
}
}
} | php | protected static function autoload($className)
{
$root_dir = Lb::app()->getRootDir();
if ($root_dir) {
$className = str_replace('..', '', $className);
// Auto Load Controllers
if (strpos($className, 'app\controllers\\') === 0) {
$controllers_dir = $root_dir . DIRECTORY_SEPARATOR . 'controllers';
if (is_dir($controllers_dir)) {
$class_file_path = $controllers_dir . DIRECTORY_SEPARATOR . str_replace('app\controllers\\', '', $className) . 'Controller.php';
Lb::app()->import(str_replace('\\', DIRECTORY_SEPARATOR, $class_file_path));
}
}
// Auto Load Models
if (strpos($className, 'app\models\\') === 0) {
$models_dir = $root_dir . DIRECTORY_SEPARATOR . 'models';
if (is_dir($models_dir)) {
$class_file_path = $models_dir . DIRECTORY_SEPARATOR . str_replace('app\models\\', '', $className) . '.php';
Lb::app()->import(str_replace('\\', DIRECTORY_SEPARATOR, $class_file_path));
}
}
// Auto Load Components
if (strpos($className, 'app\components\\') === 0) {
$components_dir = $root_dir . DIRECTORY_SEPARATOR . 'components';
if (is_dir($components_dir)) {
$class_file_path = $components_dir . DIRECTORY_SEPARATOR . str_replace('app\components\\', '', $className) . '.php';
Lb::app()->import(str_replace('\\', DIRECTORY_SEPARATOR, $class_file_path));
}
}
}
} | Autoloader | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L622-L655 |
luoxiaojun1992/lb_framework | Lb.php | Lb.loadEnv | protected function loadEnv()
{
if (defined('ENV_DIR') && file_exists(ENV_DIR)) {
if (defined('ENV_FILE') && file_exists(ENV_FILE)) {
$dotenv = new \Dotenv\Dotenv(ENV_DIR, ENV_FILE);
} else {
$dotenv = new \Dotenv\Dotenv(ENV_DIR);
}
$dotenv->load();
}
} | php | protected function loadEnv()
{
if (defined('ENV_DIR') && file_exists(ENV_DIR)) {
if (defined('ENV_FILE') && file_exists(ENV_FILE)) {
$dotenv = new \Dotenv\Dotenv(ENV_DIR, ENV_FILE);
} else {
$dotenv = new \Dotenv\Dotenv(ENV_DIR);
}
$dotenv->load();
}
} | Load Environment Variables | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L667-L677 |
luoxiaojun1992/lb_framework | Lb.php | Lb.securityHandler | protected function securityHandler()
{
$routeInfo = Lb::app()->getRouteInfo();
// Input Filter
Security::inputFilter();
// IP Filter
Security::ipFilter($routeInfo['controller'], $routeInfo['action']);
// Csrf Token Validation
Security::validCsrfToken($routeInfo['controller'], $routeInfo['action']);
// CORS
Security::cors($routeInfo['controller'], $routeInfo['action']);
// X-Frame-Options
Security::x_frame_options($routeInfo['controller'], $routeInfo['action']);
// X-XSS-Protection
Security::x_xss_protection($routeInfo['controller'], $routeInfo['action']);
} | php | protected function securityHandler()
{
$routeInfo = Lb::app()->getRouteInfo();
// Input Filter
Security::inputFilter();
// IP Filter
Security::ipFilter($routeInfo['controller'], $routeInfo['action']);
// Csrf Token Validation
Security::validCsrfToken($routeInfo['controller'], $routeInfo['action']);
// CORS
Security::cors($routeInfo['controller'], $routeInfo['action']);
// X-Frame-Options
Security::x_frame_options($routeInfo['controller'], $routeInfo['action']);
// X-XSS-Protection
Security::x_xss_protection($routeInfo['controller'], $routeInfo['action']);
} | Security Handler | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L694-L715 |
luoxiaojun1992/lb_framework | Lb.php | Lb.initLoginRequired | protected function initLoginRequired()
{
$routeInfo = Lb::app()->getRouteInfo();
if (!in_array($routeInfo['controller'], Route::KERNEL_WEB_CTR)
|| !in_array($routeInfo['action'], Route::KERNEL_WEB_ACTIONS)
) {
$login_required_filter = Lb::app()->getLoginRequiredFilter();
if (!isset($login_required_filter['controllers'][$routeInfo['controller']][$routeInfo['action']])
|| !$login_required_filter['controllers'][$routeInfo['controller']][$routeInfo['action']]
) {
$login_default_url = Lb::app()->getLoginDefaultUrl();
if (Lb::app()->isLoginRequired() && $login_default_url) {
Lb::app()->loginRequired($login_default_url);
}
}
}
} | php | protected function initLoginRequired()
{
$routeInfo = Lb::app()->getRouteInfo();
if (!in_array($routeInfo['controller'], Route::KERNEL_WEB_CTR)
|| !in_array($routeInfo['action'], Route::KERNEL_WEB_ACTIONS)
) {
$login_required_filter = Lb::app()->getLoginRequiredFilter();
if (!isset($login_required_filter['controllers'][$routeInfo['controller']][$routeInfo['action']])
|| !$login_required_filter['controllers'][$routeInfo['controller']][$routeInfo['action']]
) {
$login_default_url = Lb::app()->getLoginDefaultUrl();
if (Lb::app()->isLoginRequired() && $login_default_url) {
Lb::app()->loginRequired($login_default_url);
}
}
}
} | Init Login Required | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L720-L736 |
luoxiaojun1992/lb_framework | Lb.php | Lb.setRouteInfo | protected function setRouteInfo()
{
$this->route_info = php_sapi_name() === 'cli' ? Route::getConsoleInfo() : Route::getWebInfo();
if (!$this->route_info['controller'] || !$this->route_info['action']) {
$this->route_info['controller'] = 'index';
$this->route_info['action'] = 'index';
$home = Lb::app()->getHome();
if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$this->route_info['controller'] = $home['controller'];
$this->route_info['action'] = $home['action'];
}
}
$route_info_container = RouteInfo::component();
foreach ($this->route_info as $item_name => $item_value) {
$route_info_container->set($item_name, $item_value);
}
$this->route_info = [];
Lb::app()->containers['route_info'] = $route_info_container;
} | php | protected function setRouteInfo()
{
$this->route_info = php_sapi_name() === 'cli' ? Route::getConsoleInfo() : Route::getWebInfo();
if (!$this->route_info['controller'] || !$this->route_info['action']) {
$this->route_info['controller'] = 'index';
$this->route_info['action'] = 'index';
$home = Lb::app()->getHome();
if (isset($home['controller']) && isset($home['action']) && $home['controller'] && $home['action']) {
$this->route_info['controller'] = $home['controller'];
$this->route_info['action'] = $home['action'];
}
}
$route_info_container = RouteInfo::component();
foreach ($this->route_info as $item_name => $item_value) {
$route_info_container->set($item_name, $item_value);
}
$this->route_info = [];
Lb::app()->containers['route_info'] = $route_info_container;
} | Set Route Info | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L741-L759 |
luoxiaojun1992/lb_framework | Lb.php | Lb.registerFacades | protected function registerFacades()
{
$facades = array_merge(
[
'RedisKit' => RedisFacade::class,
'MemcacheKit' => MemcacheFacade::class,
'FilecacheKit' => FilecacheFacade::class,
'RequestKit' => RequestFacade::class,
'ResponseKit' => ResponseFacade::class,
], Lb::app()->getFacadesConfig()
);
array_walk(
$facades, function ($facade, $alias) {
class_alias($facade, $alias);
}
);
} | php | protected function registerFacades()
{
$facades = array_merge(
[
'RedisKit' => RedisFacade::class,
'MemcacheKit' => MemcacheFacade::class,
'FilecacheKit' => FilecacheFacade::class,
'RequestKit' => RequestFacade::class,
'ResponseKit' => ResponseFacade::class,
], Lb::app()->getFacadesConfig()
);
array_walk(
$facades, function ($facade, $alias) {
class_alias($facade, $alias);
}
);
} | Register Facades | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L764-L781 |
luoxiaojun1992/lb_framework | Lb.php | Lb.initSession | protected function initSession($response = null)
{
if (!$response) {
if ($session_config = Lb::app()->getSessionConfig()) {
if (isset($session_config['type'])) {
$route_info = Lb::app()->getRouteInfo();
$controller = $route_info['controller'];
$action = $route_info['action'];
if (empty($session_config['filter'][$controller][$action])) {
Session::setSession($session_config['type']);
}
}
}
}
$response ? $response->startSession() : ResponseKit::startSession();
} | php | protected function initSession($response = null)
{
if (!$response) {
if ($session_config = Lb::app()->getSessionConfig()) {
if (isset($session_config['type'])) {
$route_info = Lb::app()->getRouteInfo();
$controller = $route_info['controller'];
$action = $route_info['action'];
if (empty($session_config['filter'][$controller][$action])) {
Session::setSession($session_config['type']);
}
}
}
}
$response ? $response->startSession() : ResponseKit::startSession();
} | Init Session
@param $response ResponseContract | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L788-L803 |
luoxiaojun1992/lb_framework | Lb.php | Lb.init | public function init()
{
$this->initCommon();
if (php_sapi_name() !== 'cli') {
if (!Lb::app()->isAction()) {
throw new HttpException(self::PAGE_NOT_FOUND, 404);
}
$this->initWebApp();
} else {
$this->initConsoleApp();
}
} | php | public function init()
{
$this->initCommon();
if (php_sapi_name() !== 'cli') {
if (!Lb::app()->isAction()) {
throw new HttpException(self::PAGE_NOT_FOUND, 404);
}
$this->initWebApp();
} else {
$this->initConsoleApp();
}
} | Init Application
@throws HttpException | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L810-L823 |
luoxiaojun1992/lb_framework | Lb.php | Lb.initCommon | protected function initCommon()
{
// Load Environment Variables
$this->loadEnv();
// Include Helper Functions
include_once __DIR__ . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'Functions.php';
// Init Config
/**
* @var Scheduler $scheduler
*/
$scheduler = Scheduler::component();
//Pre autoload
if (defined('ROOT_DIR')) {
// Autoload
spl_autoload_register(['self', 'autoload'], true, false);
}
$scheduler->newTask($this->initConfig());
$scheduler->run();
// Set mb internal encoding
mb_internal_encoding(Lb::app()->getMbInternalEncoding() ?: 'UTF-8');
// Set Timezone
$this->setDefaultTimeZone();
// Register Facades
$this->registerFacades();
//Defer autoload
if (!defined('ROOT_DIR')) {
// Autoload
spl_autoload_register(['self', 'autoload'], true, false);
}
// Set Error Level
Level::set();
// Route
$this->setRouteInfo();
//Register Events
$eventsConfig = Lb::app()->getConfigByName('events');
if ($eventsConfig) {
foreach ($eventsConfig as $event => $handlers) {
foreach ($handlers as $handler) {
Lb::app()->on($event, new $handler());
}
}
}
//Register shutdown function
register_shutdown_function(
function () {
Lb::app()->trigger(Event::SHUTDOWN_EVENT);
}
);
} | php | protected function initCommon()
{
// Load Environment Variables
$this->loadEnv();
// Include Helper Functions
include_once __DIR__ . DIRECTORY_SEPARATOR . 'components' . DIRECTORY_SEPARATOR . 'Functions.php';
// Init Config
/**
* @var Scheduler $scheduler
*/
$scheduler = Scheduler::component();
//Pre autoload
if (defined('ROOT_DIR')) {
// Autoload
spl_autoload_register(['self', 'autoload'], true, false);
}
$scheduler->newTask($this->initConfig());
$scheduler->run();
// Set mb internal encoding
mb_internal_encoding(Lb::app()->getMbInternalEncoding() ?: 'UTF-8');
// Set Timezone
$this->setDefaultTimeZone();
// Register Facades
$this->registerFacades();
//Defer autoload
if (!defined('ROOT_DIR')) {
// Autoload
spl_autoload_register(['self', 'autoload'], true, false);
}
// Set Error Level
Level::set();
// Route
$this->setRouteInfo();
//Register Events
$eventsConfig = Lb::app()->getConfigByName('events');
if ($eventsConfig) {
foreach ($eventsConfig as $event => $handlers) {
foreach ($handlers as $handler) {
Lb::app()->on($event, new $handler());
}
}
}
//Register shutdown function
register_shutdown_function(
function () {
Lb::app()->trigger(Event::SHUTDOWN_EVENT);
}
);
} | Common init | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L828-L888 |
luoxiaojun1992/lb_framework | Lb.php | Lb.initWebApp | protected function initWebApp()
{
// Init Session
$this->initSession();
// Login Required
$this->initLoginRequired();
// Log
Lb::app()->log(
Lb::app()->getHostAddress() . ' visit ' . Lb::app()->getUri() . Lb::app()->getQueryString(),
Lb::app()->getRouteInfo()
);
// Security Handler
$this->securityHandler();
// Set Http Cache
$this->setHttpCache();
} | php | protected function initWebApp()
{
// Init Session
$this->initSession();
// Login Required
$this->initLoginRequired();
// Log
Lb::app()->log(
Lb::app()->getHostAddress() . ' visit ' . Lb::app()->getUri() . Lb::app()->getQueryString(),
Lb::app()->getRouteInfo()
);
// Security Handler
$this->securityHandler();
// Set Http Cache
$this->setHttpCache();
} | Init Web Application | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L893-L912 |
luoxiaojun1992/lb_framework | Lb.php | Lb.getPageCache | protected function getPageCache($cache_type)
{
$route_info = Lb::app()->getRouteInfo();
$page_cache_key = implode('_', ['page_cache', $route_info['controller'], $route_info['action']]);
return Lb::app()->getCache($page_cache_key, $cache_type);
} | php | protected function getPageCache($cache_type)
{
$route_info = Lb::app()->getRouteInfo();
$page_cache_key = implode('_', ['page_cache', $route_info['controller'], $route_info['action']]);
return Lb::app()->getCache($page_cache_key, $cache_type);
} | Get Page Cache
@param $cache_type
@return string | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L928-L933 |
luoxiaojun1992/lb_framework | Lb.php | Lb.setPageCache | protected function setPageCache($cache_type, $page_cache, $expire = 60)
{
$route_info = Lb::app()->getRouteInfo();
$page_cache_key = implode('_', ['page_cache', $route_info['controller'], $route_info['action']]);
Lb::app()->setCache($page_cache_key, $page_cache, $cache_type, $expire);
} | php | protected function setPageCache($cache_type, $page_cache, $expire = 60)
{
$route_info = Lb::app()->getRouteInfo();
$page_cache_key = implode('_', ['page_cache', $route_info['controller'], $route_info['action']]);
Lb::app()->setCache($page_cache_key, $page_cache, $cache_type, $expire);
} | Set Page Cache
@param $cache_type
@param $page_cache
@param int $expire | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L942-L947 |
luoxiaojun1992/lb_framework | Lb.php | Lb.setHttpCache | protected function setHttpCache($response = null)
{
$http_cache_config = Lb::app()->getHttpCacheConfig();
if (isset($http_cache_config['cache_control']) && isset($http_cache_config['offset'])) {
HttpHelper::setCache($http_cache_config['cache_control'], $http_cache_config['offset'], $response);
}
} | php | protected function setHttpCache($response = null)
{
$http_cache_config = Lb::app()->getHttpCacheConfig();
if (isset($http_cache_config['cache_control']) && isset($http_cache_config['offset'])) {
HttpHelper::setCache($http_cache_config['cache_control'], $http_cache_config['offset'], $response);
}
} | Set Http Cache
@param $response ResponseContract | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L954-L960 |
luoxiaojun1992/lb_framework | Lb.php | Lb.compressPage | protected function compressPage($page_content)
{
$page_compress_config = Lb::app()->getPageCompressConfig();
$routeInfo = Lb::app()->getRouteInfo();
if (isset($page_compress_config['controllers'][$routeInfo['controller']][$routeInfo['action']])
&& $page_compress_config['controllers'][$routeInfo['controller']][$routeInfo['action']]
) {
return HtmlHelper::compress($page_content);
}
return $page_content;
} | php | protected function compressPage($page_content)
{
$page_compress_config = Lb::app()->getPageCompressConfig();
$routeInfo = Lb::app()->getRouteInfo();
if (isset($page_compress_config['controllers'][$routeInfo['controller']][$routeInfo['action']])
&& $page_compress_config['controllers'][$routeInfo['controller']][$routeInfo['action']]
) {
return HtmlHelper::compress($page_content);
}
return $page_content;
} | Compress page
@param $page_content
@return string | https://github.com/luoxiaojun1992/lb_framework/blob/12a865729e7738d7d1e07371ad7203243c4571fa/Lb.php#L968-L978 |
alexpts/php-simple-events | src/BaseEvents.php | BaseEvents.on | public function on(string $name, callable $handler, int $priority = 50, array $extraArguments = [])
{
$handlerId = $this->handler->getKey($handler);
$this->listeners[$name][$priority][$handlerId] = [
'handler' => $handler,
'extraArguments' => $extraArguments,
'priority' => $priority,
];
$this->sorted[$name] = false;
return $this;
} | php | public function on(string $name, callable $handler, int $priority = 50, array $extraArguments = [])
{
$handlerId = $this->handler->getKey($handler);
$this->listeners[$name][$priority][$handlerId] = [
'handler' => $handler,
'extraArguments' => $extraArguments,
'priority' => $priority,
];
$this->sorted[$name] = false;
return $this;
} | @param string $name
@param callable $handler
@param int $priority
@param array $extraArguments
@return $this | https://github.com/alexpts/php-simple-events/blob/215e47bdd3d8236c230ae96c1ac7ebdd7e569d87/src/BaseEvents.php#L42-L54 |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.