_id
stringlengths
2
7
title
stringlengths
3
151
partition
stringclasses
3 values
text
stringlengths
33
8k
language
stringclasses
1 value
meta_information
dict
q5200
CrudAbstract.editAction
train
public function editAction($id) { $this->initializeScaffolding(); $this->beforeRead(); $this->view->record = $this->scaffolding->doRead($id); $this->afterRead();
php
{ "resource": "" }
q5201
CrudAbstract.updateAction
train
public function updateAction($id) { $this->initializeScaffolding(); $this->checkRequest(); try { $this->beforeRead(); $this->view->record = $this->scaffolding->doRead($id); $this->afterRead(); $this->beforeUpdate(); $this->scaffolding->doUpdate($id, $this->request->getPost()); $this->flash->success($this->successMessage);
php
{ "resource": "" }
q5202
CrudAbstract.deleteAction
train
public function deleteAction($id) { $this->initializeScaffolding(); try { $this->beforeRead(); $this->view->record = $this->scaffolding->doRead($id); $this->afterRead(); $this->beforeDelete(); $this->scaffolding->doDelete($id);
php
{ "resource": "" }
q5203
DbRef.create
train
public static function create($collection, $id = null, $database = null) { if ($collection instanceof \Phalcon\Mvc\Collection) { $id = $collection->getId(); $collection = $collection->getSource(); } if ($id instanceof \Phalcon\Mvc\Collection) {
php
{ "resource": "" }
q5204
Env.usePath
train
public static function usePath($path) { # Use the document root normally set via apache if ($path === self::PATH_DOCUMENT_ROOT) { if (empty($_SERVER["DOCUMENT_ROOT"]) || !is_dir($_SERVER["DOCUMENT_ROOT"])) { throw new \InvalidArgumentException("DOCUMENT_ROOT not defined"); } static::$path = $_SERVER["DOCUMENT_ROOT"]; return; } # Get the full path of the running script and use it's directory if ($path === self::PATH_PHP_SELF) { if (empty($_SERVER["PHP_SELF"]) || !$path = realpath($_SERVER["PHP_SELF"])) { throw new \InvalidArgumentException("PHP_SELF not defined"); }
php
{ "resource": "" }
q5205
Env.getRevision
train
public static function getRevision($length = 10) { $revision = Cache::call("revision", function() { $path = static::path(".git"); if (!is_dir($path)) { return; } $head = $path . "/HEAD"; if (!file_exists($head)) { return; } $data = File::getContents($head); if (!preg_match("/ref: ([^\s]+)\s/", $data, $matches)) { return;
php
{ "resource": "" }
q5206
Env.getVars
train
public static function getVars() { if (!is_array(static::$vars)) { $path = static::path("data/env.json"); try { $vars = Json::decodeFromFile($path); } catch(\Exception $e) {
php
{ "resource": "" }
q5207
CmsAuthServiceProvider.registerAuthRepository
train
protected function registerAuthRepository() { $this->app->singleton(AuthRepositoryInterface::class, function
php
{ "resource": "" }
q5208
CmsAuthServiceProvider.registerCommands
train
protected function registerCommands() { $this->app->singleton('cms.commands.user-create', CreateUser::class); $this->app->singleton('cms.commands.user-delete', DeleteUser::class); $this->commands([
php
{ "resource": "" }
q5209
Validation.is_valid
train
public static function is_valid(array $data, array $validators) { $gump = self::get_instance(); $gump->validation_rules($validators); if ($gump->run($data) === false) {
php
{ "resource": "" }
q5210
Libraries.load
train
public static function load($path = BASE_DIR) { $librariesDir = dirname(dirname($path)) .
php
{ "resource": "" }
q5211
AuthRepository.getAllUsers
train
public function getAllUsers($withAdmin = false) { $query = $this->userModel->query()
php
{ "resource": "" }
q5212
AuthRepository.getUsersForRole
train
public function getUsersForRole($role, $withAdmin = false) { $query = $this->userModel->query() ->orderBy('email') ->whereHas('roles', function ($query) use ($role) { $query->where('slug', $role); });
php
{ "resource": "" }
q5213
AuthRepository.getAllPermissions
train
public function getAllPermissions() { $permissions = []; // Gather and combine all permissions for roles foreach ($this->roleModel->all() as $role) { $permissions = array_merge( $permissions, array_keys(array_filter($role->getPermissions()))
php
{ "resource": "" }
q5214
AuthRepository.getAllPermissionsForRole
train
public function getAllPermissionsForRole($role) { /** @var EloquentRole $role */ $role = $this->getRole($role); if ( ! $role) { return [];
php
{ "resource": "" }
q5215
AuthRepository.getAllPermissionsForUser
train
public function getAllPermissionsForUser($user) { $user = $this->resolveUser($user); if ( ! $user) { return []; } $permissions = []; // Get all permissions for the roles this user belongs to foreach ($user->getRoles() as $role) { /** @var EloquentRole $role */ $permissions = array_merge( $permissions, array_keys(array_filter($role->getPermissions())) );
php
{ "resource": "" }
q5216
AuthRepository.resolveUser
train
protected function resolveUser($user) { if ($user instanceof UserInterface) { return $user; } if (is_integer($user)) { $user = $this->sentinel->findById($user); } else {
php
{ "resource": "" }
q5217
User.signUp
train
public static function signUp(UserId $anId, UserEmail $anEmail, UserPassword $aPassword, array $userRoles) { $user = new static($anId, $anEmail, $userRoles, $aPassword); $user->confirmationToken = new UserToken(); $user->publish( new UserRegistered(
php
{ "resource": "" }
q5218
User.invite
train
public static function invite(UserId $anId, UserEmail $anEmail, array $userRoles) { $user = new static($anId, $anEmail, $userRoles); $user->invitationToken = new UserToken(); $user->publish( new UserInvited(
php
{ "resource": "" }
q5219
User.acceptInvitation
train
public function acceptInvitation() { if ($this->isInvitationTokenAccepted()) { throw new UserInvitationAlreadyAcceptedException(); } if ($this->isInvitationTokenExpired()) { throw new UserTokenExpiredException(); } $this->invitationToken = null;
php
{ "resource": "" }
q5220
User.changePassword
train
public function changePassword(UserPassword $aPassword) { $this->password = $aPassword;
php
{ "resource": "" }
q5221
User.confirmationToken
train
public function confirmationToken() { // This ternary is a hack that avoids the // DoctrineORM limitation with nullable embeddables return $this->confirmationToken instanceof UserToken
php
{ "resource": "" }
q5222
User.enableAccount
train
public function enableAccount() { $this->confirmationToken = null; $this->updatedOn = new \DateTimeImmutable(); $this->publish(
php
{ "resource": "" }
q5223
User.grant
train
public function grant(UserRole $aRole) { if (false === $this->isRoleAllowed($aRole)) { throw new UserRoleInvalidException(); } if (true === $this->isGranted($aRole)) { throw new UserRoleAlreadyGrantedException(); } $this->roles[] = $aRole;
php
{ "resource": "" }
q5224
User.invitationToken
train
public function invitationToken() { // This ternary is a hack that avoids the // DoctrineORM limitation with nullable embeddables return $this->invitationToken instanceof UserToken
php
{ "resource": "" }
q5225
User.isInvitationTokenExpired
train
public function isInvitationTokenExpired() { if (!$this->invitationToken() instanceof UserToken) { throw new UserTokenNotFoundException();
php
{ "resource": "" }
q5226
User.isRememberPasswordTokenExpired
train
public function isRememberPasswordTokenExpired() { if (!$this->rememberPasswordToken() instanceof UserToken) {
php
{ "resource": "" }
q5227
User.login
train
public function login($aPlainPassword, UserPasswordEncoder $anEncoder) { if (false === $this->isEnabled()) { throw new UserInactiveException(); } if (false === $this->password()->equals($aPlainPassword, $anEncoder)) { throw new UserPasswordInvalidException(); } $this->lastLogin =
php
{ "resource": "" }
q5228
User.logout
train
public function logout() { if (false === $this->isEnabled()) { throw new UserInactiveException(); } $this->publish( new UserLoggedOut(
php
{ "resource": "" }
q5229
User.regenerateInvitationToken
train
public function regenerateInvitationToken() { if (null === $this->invitationToken()) { throw new UserInvitationAlreadyAcceptedException(); } $this->invitationToken = new UserToken(); $this->publish(
php
{ "resource": "" }
q5230
User.rememberPasswordToken
train
public function rememberPasswordToken() { // This ternary is a hack that avoids the // DoctrineORM limitation with nullable embeddables return $this->rememberPasswordToken instanceof UserToken
php
{ "resource": "" }
q5231
User.rememberPassword
train
public function rememberPassword() { $this->rememberPasswordToken = new UserToken(); $this->publish( new UserRememberPasswordRequested( $this->id,
php
{ "resource": "" }
q5232
ElectronicAddressValidator.isValid
train
public function isValid($value) { if ($value instanceof ElectronicAddress) { $addressType = $value->getType(); switch ($addressType) { case 'Email': $addressValidator = $this->validatorResolver->createValidator('EmailAddress'); break; default: $addressValidator = $this->validatorResolver->createValidator('Neos.Party:' . $addressType . 'Address'); } if ($addressValidator === null) { $this->addError('No validator found for electronic address of type "'
php
{ "resource": "" }
q5233
CompletePurchaseResponse.isSuccessful
train
public function isSuccessful() { return $this->data->getStatus()
php
{ "resource": "" }
q5234
CompletePurchaseResponse.getTime
train
public function getTime() { $time = $this->data->getInvoiceTime(); if ($time instanceof
php
{ "resource": "" }
q5235
SentinelServiceProvider.registerSentinel
train
protected function registerSentinel() { $this->app->singleton('sentinel', function ($app) { // @codeCoverageIgnoreStart $sentinel = new Sentinel( $app['sentinel.persistence'], $app['sentinel.users'], $app['sentinel.roles'], $app['sentinel.activations'], $app['events'] ); if (isset($app['sentinel.checkpoints'])) { foreach ($app['sentinel.checkpoints'] as $key => $checkpoint) { $sentinel->addCheckpoint($key, $checkpoint); } } $sentinel->setActivationRepository($app['sentinel.activations']); $sentinel->setReminderRepository($app['sentinel.reminders']); $sentinel->setRequestCredentials(function () use ($app) { $request = $app['request']; $login = $request->getUser(); $password = $request->getPassword();
php
{ "resource": "" }
q5236
SentinelServiceProvider.registerUsers
train
protected function registerUsers() { $this->registerHasher(); $this->app->singleton('sentinel.users', function ($app) { $config = $app['config']->get('cartalyst.sentinel'); $users = array_get($config, 'users.model'); $roles = array_get($config, 'roles.model'); $persistences = array_get($config, 'persistences.model'); $permissions = array_get($config, 'permissions.class'); if (class_exists($roles) && method_exists($roles, 'setUsersModel')) { forward_static_call_array([$roles, 'setUsersModel'], [$users]); } if (class_exists($persistences) && method_exists($persistences, 'setUsersModel')) {
php
{ "resource": "" }
q5237
StagedQueryBuilder.withAddedStep
train
protected function withAddedStep(string $stage, callable $step, bool $replace = false) { $clone = clone $this; if ($replace) {
php
{ "resource": "" }
q5238
StagedQueryBuilder.withFilteredSteps
train
public function withFilteredSteps(callable $matcher) { $clone = clone $this; foreach ($clone->stages as $stage => &$steps) { $steps = array_filter($steps, function
php
{ "resource": "" }
q5239
StagedQueryBuilder.buildQuery
train
public function buildQuery(iterable $filter, array $opts = []) { return Pipeline::with($this->stages) ->flatten()
php
{ "resource": "" }
q5240
AppFactory.buildFromContainer
train
public static function buildFromContainer(ContainerInterface $container): App { return new App( self::request($container), self::response($container), self::processor($container), self::matchableRequest($container),
php
{ "resource": "" }
q5241
AppFactory.request
train
private static function request(ContainerInterface $container): ServerRequestInterface { if (!$container->has(ServerRequestInterface::class)) { throw new InvalidArgumentException('Moon received an
php
{ "resource": "" }
q5242
AppFactory.response
train
private static function response(ContainerInterface $container): ResponseInterface { if (!$container->has(ResponseInterface::class)) { throw new InvalidArgumentException('Moon received an
php
{ "resource": "" }
q5243
AppFactory.processor
train
private static function processor(ContainerInterface $container): ProcessorInterface { if (!$container->has(ProcessorInterface::class)) {
php
{ "resource": "" }
q5244
AppFactory.errorHandler
train
private static function errorHandler(ContainerInterface $container): ErrorHandlerInterface { if (!$container->has(ErrorHandlerInterface::class)) {
php
{ "resource": "" }
q5245
AppFactory.invalidRequestHandler
train
private static function invalidRequestHandler(ContainerInterface $container): InvalidRequestHandlerInterface { if (!$container->has(InvalidRequestHandlerInterface::class)) {
php
{ "resource": "" }
q5246
AppFactory.matchableRequest
train
private static function matchableRequest(ContainerInterface $container): MatchableRequestInterface { if (!$container->has(MatchableRequestInterface::class)) {
php
{ "resource": "" }
q5247
AppFactory.streamReadLength
train
private static function streamReadLength(ContainerInterface $container): ? int {
php
{ "resource": "" }
q5248
SelfInitializingFixtureTrait.getFixtureFingerprintArguments
train
protected function getFixtureFingerprintArguments(array $arguments) { $fingerprintArguments = array(); foreach ($arguments as $arg) { if (is_object($arg) && method_exists($arg, '__toString')) { $fingerprintArg = (string)$arg; }
php
{ "resource": "" }
q5249
LdapClient.bind
train
public function bind($bindUser = null, $bindPass = null) { if (false === ldap_bind($this->ldapResource, $bindUser, $bindPass)) { throw new LdapClientException( sprintf(
php
{ "resource": "" }
q5250
Session.getFlash
train
public function getFlash($key) { if ($this->has($key)) {
php
{ "resource": "" }
q5251
LoaderInitializerTrait.initLoader
train
public function initLoader(Config $config) { $loader = new Loader(); $loader->registerDirs( [
php
{ "resource": "" }
q5252
PartyRepository.findOneHavingAccount
train
public function findOneHavingAccount(Account $account) { $query = $this->createQuery();
php
{ "resource": "" }
q5253
ConfiguredFieldMap.apply
train
protected function apply(iterable $iterable): iterable { return Pipeline::with($iterable) ->mapKeys(function($_, $info) { $field = is_array($info) ? ($info['field'] ?? null) : $info; $newField = $this->map[$field] ?? ($this->dynamic ? $field : null);
php
{ "resource": "" }
q5254
Router.addRoute
train
public function addRoute(array $routeArray) { $routeKeys = array_keys($routeArray); $routeValues = array_values($routeArray); $routeName = reset($routeKeys);
php
{ "resource": "" }
q5255
Router.addModuleRoutes
train
public function addModuleRoutes(array $module) { $routeArray = $this->getRouteArrayFromModulePath($module['path']);
php
{ "resource": "" }
q5256
Router.getRouteArrayFromModulePath
train
private function getRouteArrayFromModulePath($path) { $path = dirname($path).'/config/routes.php'; if (file_exists($path) && is_file($path)) {
php
{ "resource": "" }
q5257
Router.groupRoutes
train
private function groupRoutes() { $routes = array(); foreach ($this->routeTypes as $type => $typeName) { $routes[$type] = array(); } foreach ($this->routes as $routePattern => $route)
php
{ "resource": "" }
q5258
Router.setup
train
public function setup() { $this->groupRoutes(); foreach ($this->routes as $type => $routes) { foreach ($routes as $name => $route) { $newRoute = new Route($name, $route); if (!$newRoute->hasParam('hostname')) {
php
{ "resource": "" }
q5259
Router.resolveRouteType
train
private function resolveRouteType($routeType) { $typeClassName = sprintf('%sRoute', ucfirst($routeType)); $classNamespace = __NAMESPACE__ . '\\Router\\Route\\' . $typeClassName;
php
{ "resource": "" }
q5260
Cookie.get
train
public static function get($key) { return self::has($key) ?
php
{ "resource": "" }
q5261
Cookie.set
train
public static function set($key, $value = '', $time = 0, $path = '/', $domain = '', $secure = FALSE,
php
{ "resource": "" }
q5262
Cookie.delete
train
public static function delete($key, $path = '/') { if (self::has($key)) {
php
{ "resource": "" }
q5263
Cookie.flush
train
public static function flush() { if (count($_COOKIE) > 0) { foreach ($_COOKIE as $key => $value) {
php
{ "resource": "" }
q5264
App.run
train
public function run(MatchablePipelineCollectionInterface $pipelines): ResponseInterface { try { // If a pipeline match print the response and return if ($handledResponse = $this->handlePipeline($pipelines)) { return $handledResponse; } // If a route pattern matched but the http verbs was different, print a '405 response' // If no route pattern matched, print a '404 response'
php
{ "resource": "" }
q5265
App.handlePipeline
train
private function handlePipeline(MatchablePipelineCollectionInterface $pipelines): ?ResponseInterface { /** @var MatchablePipelineInterface $pipeline */ foreach ($pipelines as $pipeline) { if ($pipeline->matchBy($this->matchableRequest)) { $stages = \array_merge($this->stages(), $pipeline->stages());
php
{ "resource": "" }
q5266
App.sendResponse
train
public function sendResponse(ResponseInterface $response): void { // Send all the headers \http_response_code($response->getStatusCode()); foreach ($response->getHeaders() as $headerName => $headerValues) { /** @var string[] $headerValues */ foreach ($headerValues as $headerValue) { \header("$headerName: $headerValue", false); } }
php
{ "resource": "" }
q5267
Qt_Model.fillObjectProps
train
public function fillObjectProps($arguments) { foreach ($arguments as $key => $value) { if (!in_array($key, $this->fillable)) {
php
{ "resource": "" }
q5268
Debug.output
train
public static function output($message, $data = null) { if (static::$mode == "html") { static::html($message, $data);
php
{ "resource": "" }
q5269
Debug.indent
train
protected static function indent() { $char = (static::$mode == "html") ? " " : " ";
php
{ "resource": "" }
q5270
Debug.text
train
public static function text($message, $data = null) { if (!static::$on) { return; } echo "--------------------------------------------------------------------------------\n"; static::indent(); echo static::getTime() . " - " . $message . "\n"; if
php
{ "resource": "" }
q5271
Debug.html
train
public static function html($message, $data = null) { if (!static::$on) { return; } echo "<hr>"; echo "<i>"; static::indent(); echo "<b>" . static::getTime() . " - " . $message . "</b>"; if (is_array($data)) {
php
{ "resource": "" }
q5272
Debug.call
train
public static function call($message, callable $func) { $time = microtime(true); static::output($message . " [START]"); static::$indent++; $func(); static::$indent--;
php
{ "resource": "" }
q5273
UserToken.isExpired
train
public function isExpired($lifetime) { $interval = $this->createdOn->diff(new \DateTimeImmutable());
php
{ "resource": "" }
q5274
Result.resolveMeta
train
protected function resolveMeta(): void { expect_type($this->meta, 'callable', \BadMethodCallException::class); $meta = i\function_call($this->meta);
php
{ "resource": "" }
q5275
LocaleSubscriber.getLocaleFromTypo3
train
private function getLocaleFromTypo3(Request $request): ?string { $locale = null; if ((bool) $language = $request->attributes->get('language')) { /* @var SiteLanguage $language */ [$locale] = \explode('.', $language->getLocale()); } elseif ((bool) $site = $request->attributes->get('site')) {
php
{ "resource": "" }
q5276
LocaleSubscriber.getDenormalizedLocaleFromTypo3
train
private function getDenormalizedLocaleFromTypo3(Request $request): ?string { if ((bool) $language = $request->attributes->get('language')) { /* @var SiteLanguage $language */ return \trim($language->getBase()->getPath(), '/'); } if ((bool) $site
php
{ "resource": "" }
q5277
W3CMarkupValidator.getValidationData
train
private function getValidationData($markup) { $this->httpRequestParameters['body'] = $markup; $reponse = $this->httpClient->post( $this->configuration[self::ENDPOINT_CONFIG_KEY], $this->httpRequestParameters ); $responseData = $reponse->getBody()->getContents(); $validationData = json_decode($responseData, true);
php
{ "resource": "" }
q5278
W3CMarkupValidator.getValidationMessages
train
private function getValidationMessages(array $validationData) { $messages = array(); $messagesData = $validationData['messages']; foreach ($messagesData as $messageData) {
php
{ "resource": "" }
q5279
EloquentUser.can
train
public function can($permission, $allowAny = false) { if ($allowAny) { return $this->hasAnyAccess( is_array($permission) ? $permission : [ $permission ] ); }
php
{ "resource": "" }
q5280
PersonNameValidator.isValid
train
public function isValid($value) { if ($value instanceof PersonName) { if (strlen(trim($value->getFullName())) === 0) {
php
{ "resource": "" }
q5281
RegisterHelpersTrait.registerHelpers
train
public function registerHelpers() { foreach (glob($this->getHelpersDirectoryPath() . '*.php') as $file) { $helperName = pathinfo($file,
php
{ "resource": "" }
q5282
EnvironmentInitializerTrait.initEnvironment
train
public function initEnvironment(Config $config) { if (isset($config->application) && isset($config->application->environment)) { $env = $config->application->environment; } else { $env = Constants::DEFAULT_ENV; }
php
{ "resource": "" }
q5283
Loader.dump
train
public function dump($inputDirectory, $outputDirectory, $dumpVendorModules = true) { $modulesList = []; //extracts list of modules from module directory $directoryIterator = new \DirectoryIterator($inputDirectory); foreach ($directoryIterator as $moduleDir) { if ($moduleDir->isDot()) { continue; } $moduleSettingsFile = $moduleDir->getPathname() . DIRECTORY_SEPARATOR . self::MODULE_SETTINGS_FILE; if (!file_exists($moduleSettingsFile)) { continue; } $modulesList[$moduleDir->getBasename()] = [ 'className' => $moduleDir->getBasename() . '\\'
php
{ "resource": "" }
q5284
Loader.dumpModulesFromVendor
train
public function dumpModulesFromVendor(array &$modulesList) { if (!file_exists(APP_ROOT.'/composer.json')) { return $modulesList; } $fileContent = file_get_contents(APP_ROOT . DIRECTORY_SEPARATOR . 'composer.json'); $json = json_decode($fileContent, true); $vendorDir = realpath(APP_ROOT . ( isset($json['config']['vendor-dir']) ? DIRECTORY_SEPARATOR . $json['config']['vendor-dir']
php
{ "resource": "" }
q5285
Loader.dumpSingleProviderModulesFromVendor
train
private function dumpSingleProviderModulesFromVendor(array &$modulesList, $providerDir) { $directoryIterator = new \DirectoryIterator($providerDir); foreach ($directoryIterator as $libDir) { if ($libDir->isDot()) { continue; } //creates path to Module.php file $moduleSettingsFile = implode(DIRECTORY_SEPARATOR, [ $providerDir, $libDir, 'module', self::MODULE_SETTINGS_FILE ]); if (!file_exists($moduleSettingsFile)) { continue;
php
{ "resource": "" }
q5286
Loader.getModuleProviders
train
private function getModuleProviders() { $defaultProviders = [ 'vegas-cmf' ]; $appConfig = $this->di->get('config')->application; if (!isset($appConfig->vendorModuleProvider)) { $providerNames = []; } else if (is_string($appConfig->vendorModuleProvider)) {
php
{ "resource": "" }
q5287
Curl.getResponseHeaders
train
public function getResponseHeaders() { $requestHeaders = []; if ($this->headers instanceof \ArrayAccess) { while ($this->headers->valid()) { $requestHeaders[$this->headers->key()]
php
{ "resource": "" }
q5288
Debugger.runDebuger
train
public static function runDebuger($view = null) { self::$debugbar = new Debugger(); self::$assets_url = base_url() . '/assets/DebugBar/Resources'; self::addQueries(); self::addMessages(); self::addRoute($view);
php
{ "resource": "" }
q5289
Debugger.addQueries
train
private static function addQueries() { self::$debugbar->addCollector(new MessagesCollector('queries')); self::$queries = ORM::get_query_log(); if (self::$queries) {
php
{ "resource": "" }
q5290
Debugger.addRoute
train
private static function addRoute($view) { $uri = RouteController::$currentRoute['uri']; $method = RouteController::$currentRoute['method']; $module = RouteController::$currentRoute['module']; $current_controller = 'modules' . DS . $module . DS . RouteController::$currentRoute['controller']; $current_action = RouteController::$currentRoute['action']; $args = RouteController::$currentRoute['args']; $route = [ 'Route' => $uri, 'Method' => $method, 'Module' => $module,
php
{ "resource": "" }
q5291
Debugger.addMessages
train
private static function addMessages() { $out_data = session()->get('output'); if ($out_data) { foreach ($out_data as $data) {
php
{ "resource": "" }
q5292
ExecuteCommand.execute
train
public function execute(Input $input): void { $this->bus->handle(
php
{ "resource": "" }
q5293
Scaffolding.processForm
train
private function processForm($values) { $form = $this->getForm($this->record); $form->bind($values, $this->record); if ($form->isValid()) {
php
{ "resource": "" }
q5294
Image.resize
train
public static function resize($options = null) { $options = Helper::getOptions($options, [ "fromPath" => null, "toPath" => null, "width" => null, "height" => null, ]); if (!$fromPath = trim($options["fromPath"])) { throw new \Exception("No from path specified to read from"); } if (!$toPath = trim($options["toPath"])) { throw new \Exception("No to path specified to save to"); } $maxWidth = round($options["width"]); $maxHeight = round($options["height"]); list($width, $height, $format) = getimagesize($fromPath); if ($width < 1 || $height < 1) { copy($fromPath, $toPath); return; } if ($maxWidth < 1 && $maxHeight < 1) { copy($fromPath, $toPath);
php
{ "resource": "" }
q5295
Image.img
train
public static function img($options = null) { $options = Helper::getOptions($options, [ "path" => "images/img", "basename" => null, "filename" => null, "width" => null, "height" => null, ]); $path = $options["path"]; if ($path[0] == "/") { $fullpath = $path; } else { $fullpath = Env::path($path, Env::PATH_DOCUMENT_ROOT); } $filename = $options["filename"]; if ($basename = $options["basename"]) { $original = $fullpath . "/original/" . $basename; if (file_exists($original)) { if ($ext = static::getExtension($original)) { $filename = $basename . "." . $ext; copy($original, $fullpath . "/original/" . $filename); } } } if (!$filename) { throw new \Exception("No image filename provided to use"); } $original = $fullpath . "/original/" . $filename; if (!file_exists($original)) { throw new \Exception("Original image file does not exist (" . $original . ")"); }
php
{ "resource": "" }
q5296
Image.create
train
public static function create($path, $format) { switch ($format) { case IMAGETYPE_JPEG: $result = imagecreatefromjpeg($path); break; case IMAGETYPE_PNG: $result = imagecreatefrompng($path); break; case IMAGETYPE_GIF: $result = imagecreatefromgif($path);
php
{ "resource": "" }
q5297
Image.save
train
public static function save($image, $path, $format) { switch ($format) { case IMAGETYPE_JPEG: $result = imagejpeg($image, $path, 100); break; case IMAGETYPE_PNG:
php
{ "resource": "" }
q5298
Image.rotate
train
public static function rotate($path, $rotate = null) { if ($rotate === null) { $exif = exif_read_data($path); switch ($exif["Orientation"]) { case 3: $rotate = 180; break; case 6: $rotate = 90; break; case 8: $rotate = -90; break; } } if (!$rotate) {
php
{ "resource": "" }
q5299
View._engineRender
train
protected function _engineRender($engines, $viewPath, $silence, $mustClean, $cache) { $basePath = $this->_basePath; $notExists = true; if (is_object($cache)) { $renderLevel = intval($this->_renderLevel); $cacheLevel = intval($this->_cacheLevel); if ($renderLevel >= $cacheLevel) { if ($cache->isStarted() === false) { $viewOptions = $this->_options; if (is_array($viewOptions)) { if (isset($viewOptions['cache'])) { $cacheOptions = $viewOptions['cache']; if (is_array($cacheOptions)) { if (isset($cacheOptions['key'])) { $key = $cacheOptions['key']; } if (isset($cacheOptions['lifetime'])) { $lifeTime = $cacheOptions['lifetime']; } } if (!isset($key) || !$key) { $key = md5($viewPath); } if (!isset($lifeTime)) { $lifeTime = 0; } $cachedView = $cache->start($key, $lifeTime); if (!$cachedView) { $this->_content = $cachedView; return null; } } if (!$cache->isFresh()) {
php
{ "resource": "" }