repo
stringlengths
6
63
path
stringlengths
5
140
func_name
stringlengths
3
151
original_string
stringlengths
84
13k
language
stringclasses
1 value
code
stringlengths
84
13k
code_tokens
list
docstring
stringlengths
3
47.2k
docstring_tokens
list
sha
stringlengths
40
40
url
stringlengths
91
247
partition
stringclasses
1 value
themosis/framework
src/Core/Console/ThemeInstallCommand.php
ThemeInstallCommand.installTheme
protected function installTheme(string $name) { $this->info('Downloading theme...'); $this->files->put($this->temp, fopen($this->option('url'), 'r')); if (true !== $this->zip->open($this->temp)) { $this->error('Cannot open theme zip file.'); } $this->zip->extractTo(themes_path()); $this->zip->close(); $this->files->move( themes_path($this->option('dir')), themes_path(str_replace(' ', '-', $name)) ); $this->files->delete($this->temp); }
php
protected function installTheme(string $name) { $this->info('Downloading theme...'); $this->files->put($this->temp, fopen($this->option('url'), 'r')); if (true !== $this->zip->open($this->temp)) { $this->error('Cannot open theme zip file.'); } $this->zip->extractTo(themes_path()); $this->zip->close(); $this->files->move( themes_path($this->option('dir')), themes_path(str_replace(' ', '-', $name)) ); $this->files->delete($this->temp); }
[ "protected", "function", "installTheme", "(", "string", "$", "name", ")", "{", "$", "this", "->", "info", "(", "'Downloading theme...'", ")", ";", "$", "this", "->", "files", "->", "put", "(", "$", "this", "->", "temp", ",", "fopen", "(", "$", "this", "->", "option", "(", "'url'", ")", ",", "'r'", ")", ")", ";", "if", "(", "true", "!==", "$", "this", "->", "zip", "->", "open", "(", "$", "this", "->", "temp", ")", ")", "{", "$", "this", "->", "error", "(", "'Cannot open theme zip file.'", ")", ";", "}", "$", "this", "->", "zip", "->", "extractTo", "(", "themes_path", "(", ")", ")", ";", "$", "this", "->", "zip", "->", "close", "(", ")", ";", "$", "this", "->", "files", "->", "move", "(", "themes_path", "(", "$", "this", "->", "option", "(", "'dir'", ")", ")", ",", "themes_path", "(", "str_replace", "(", "' '", ",", "'-'", ",", "$", "name", ")", ")", ")", ";", "$", "this", "->", "files", "->", "delete", "(", "$", "this", "->", "temp", ")", ";", "}" ]
Install theme. @param string $name The theme name from user
[ "Install", "theme", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Console/ThemeInstallCommand.php#L72-L90
train
themosis/framework
src/Core/Console/ThemeInstallCommand.php
ThemeInstallCommand.setupTheme
protected function setupTheme(string $name) { $this->info('Set [style.css] file...'); $theme = ucwords(str_replace(['-', '_'], ' ', $name)); $textdomain = str_replace(['-', ' '], '_', strtolower($name)); $content = <<<STYLES /* Theme Name: $theme Theme URI: https://framework.themosis.com/ Author: Themosis Author URI: https://www.themosis.com/ Description: The Themosis framework base theme. Version: 1.0.0 License: GPL-2.0-or-later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: easy, organized, expressive. Text Domain: $textdomain Domain Path: languages */ STYLES; $this->files->put(themes_path($name.'/style.css'), $content); }
php
protected function setupTheme(string $name) { $this->info('Set [style.css] file...'); $theme = ucwords(str_replace(['-', '_'], ' ', $name)); $textdomain = str_replace(['-', ' '], '_', strtolower($name)); $content = <<<STYLES /* Theme Name: $theme Theme URI: https://framework.themosis.com/ Author: Themosis Author URI: https://www.themosis.com/ Description: The Themosis framework base theme. Version: 1.0.0 License: GPL-2.0-or-later License URI: http://www.gnu.org/licenses/gpl-2.0.html Tags: easy, organized, expressive. Text Domain: $textdomain Domain Path: languages */ STYLES; $this->files->put(themes_path($name.'/style.css'), $content); }
[ "protected", "function", "setupTheme", "(", "string", "$", "name", ")", "{", "$", "this", "->", "info", "(", "'Set [style.css] file...'", ")", ";", "$", "theme", "=", "ucwords", "(", "str_replace", "(", "[", "'-'", ",", "'_'", "]", ",", "' '", ",", "$", "name", ")", ")", ";", "$", "textdomain", "=", "str_replace", "(", "[", "'-'", ",", "' '", "]", ",", "'_'", ",", "strtolower", "(", "$", "name", ")", ")", ";", "$", "content", "=", " <<<STYLES\n/*\nTheme Name: $theme\nTheme URI: https://framework.themosis.com/\nAuthor: Themosis\nAuthor URI: https://www.themosis.com/\nDescription: The Themosis framework base theme.\nVersion: 1.0.0\nLicense: GPL-2.0-or-later\nLicense URI: http://www.gnu.org/licenses/gpl-2.0.html\nTags: easy, organized, expressive.\nText Domain: $textdomain\nDomain Path: languages\n*/\nSTYLES", ";", "$", "this", "->", "files", "->", "put", "(", "themes_path", "(", "$", "name", ".", "'/style.css'", ")", ",", "$", "content", ")", ";", "}" ]
Setup basic theme information. @param string $name
[ "Setup", "basic", "theme", "information", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Console/ThemeInstallCommand.php#L97-L121
train
themosis/framework
src/Core/Console/ThemeInstallCommand.php
ThemeInstallCommand.setAsDefaultTheme
protected function setAsDefaultTheme(string $name) { if (! file_exists($file = config_path('wordpress.php'))) { $this->warn('Cannot update default theme configuration.'); return; } $this->info('Set default theme constant...'); $lines = file($file); $content = array_map(function ($line) use ($name) { if (stristr($line, 'WP_DEFAULT_THEME')) { return "define('WP_DEFAULT_THEME', '{$name}');\r\n"; } return $line; }, $lines); $this->files->put($file, implode('', $content)); }
php
protected function setAsDefaultTheme(string $name) { if (! file_exists($file = config_path('wordpress.php'))) { $this->warn('Cannot update default theme configuration.'); return; } $this->info('Set default theme constant...'); $lines = file($file); $content = array_map(function ($line) use ($name) { if (stristr($line, 'WP_DEFAULT_THEME')) { return "define('WP_DEFAULT_THEME', '{$name}');\r\n"; } return $line; }, $lines); $this->files->put($file, implode('', $content)); }
[ "protected", "function", "setAsDefaultTheme", "(", "string", "$", "name", ")", "{", "if", "(", "!", "file_exists", "(", "$", "file", "=", "config_path", "(", "'wordpress.php'", ")", ")", ")", "{", "$", "this", "->", "warn", "(", "'Cannot update default theme configuration.'", ")", ";", "return", ";", "}", "$", "this", "->", "info", "(", "'Set default theme constant...'", ")", ";", "$", "lines", "=", "file", "(", "$", "file", ")", ";", "$", "content", "=", "array_map", "(", "function", "(", "$", "line", ")", "use", "(", "$", "name", ")", "{", "if", "(", "stristr", "(", "$", "line", ",", "'WP_DEFAULT_THEME'", ")", ")", "{", "return", "\"define('WP_DEFAULT_THEME', '{$name}');\\r\\n\"", ";", "}", "return", "$", "line", ";", "}", ",", "$", "lines", ")", ";", "$", "this", "->", "files", "->", "put", "(", "$", "file", ",", "implode", "(", "''", ",", "$", "content", ")", ")", ";", "}" ]
Set default theme constant in main "wordpress.php" config file. @param string $name
[ "Set", "default", "theme", "constant", "in", "main", "wordpress", ".", "php", "config", "file", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Console/ThemeInstallCommand.php#L128-L148
train
themosis/framework
src/Core/PluginsRepository.php
PluginsRepository.load
public function load(array $directories) { $manifest = $this->loadManifest(); if ($this->shouldRecompile($manifest, $directories)) { $manifest = $this->compileManifest($directories); } // Load plugins defined in the manifest. // Dispatch an event with loaded plugin data. foreach ($manifest as $plugin => $headers) { $path = sprintf('%s/%s', $plugin, $headers['root']); $this->app->registerPlugin($path); $this->app['events']->dispatch( new PluginLoaded($plugin, $headers) ); } }
php
public function load(array $directories) { $manifest = $this->loadManifest(); if ($this->shouldRecompile($manifest, $directories)) { $manifest = $this->compileManifest($directories); } // Load plugins defined in the manifest. // Dispatch an event with loaded plugin data. foreach ($manifest as $plugin => $headers) { $path = sprintf('%s/%s', $plugin, $headers['root']); $this->app->registerPlugin($path); $this->app['events']->dispatch( new PluginLoaded($plugin, $headers) ); } }
[ "public", "function", "load", "(", "array", "$", "directories", ")", "{", "$", "manifest", "=", "$", "this", "->", "loadManifest", "(", ")", ";", "if", "(", "$", "this", "->", "shouldRecompile", "(", "$", "manifest", ",", "$", "directories", ")", ")", "{", "$", "manifest", "=", "$", "this", "->", "compileManifest", "(", "$", "directories", ")", ";", "}", "// Load plugins defined in the manifest.", "// Dispatch an event with loaded plugin data.", "foreach", "(", "$", "manifest", "as", "$", "plugin", "=>", "$", "headers", ")", "{", "$", "path", "=", "sprintf", "(", "'%s/%s'", ",", "$", "plugin", ",", "$", "headers", "[", "'root'", "]", ")", ";", "$", "this", "->", "app", "->", "registerPlugin", "(", "$", "path", ")", ";", "$", "this", "->", "app", "[", "'events'", "]", "->", "dispatch", "(", "new", "PluginLoaded", "(", "$", "plugin", ",", "$", "headers", ")", ")", ";", "}", "}" ]
Load application must-use plugins. @param array $directories @throws \Illuminate\Contracts\Filesystem\FileNotFoundException @throws Exception
[ "Load", "application", "must", "-", "use", "plugins", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginsRepository.php#L51-L68
train
themosis/framework
src/Core/PluginsRepository.php
PluginsRepository.compileManifest
public function compileManifest(array $directories) { $manifest = []; foreach ($directories as $directory) { // Find the root file of each plugin. // As we load the plugins from the mu-plugins directory // we do not need to get their header. Only the file // that defines them. if ($payload = $this->getPlugin($directory)) { $manifest[$directory] = $payload; } } return $this->writeManifest($manifest); }
php
public function compileManifest(array $directories) { $manifest = []; foreach ($directories as $directory) { // Find the root file of each plugin. // As we load the plugins from the mu-plugins directory // we do not need to get their header. Only the file // that defines them. if ($payload = $this->getPlugin($directory)) { $manifest[$directory] = $payload; } } return $this->writeManifest($manifest); }
[ "public", "function", "compileManifest", "(", "array", "$", "directories", ")", "{", "$", "manifest", "=", "[", "]", ";", "foreach", "(", "$", "directories", "as", "$", "directory", ")", "{", "// Find the root file of each plugin.", "// As we load the plugins from the mu-plugins directory", "// we do not need to get their header. Only the file", "// that defines them.", "if", "(", "$", "payload", "=", "$", "this", "->", "getPlugin", "(", "$", "directory", ")", ")", "{", "$", "manifest", "[", "$", "directory", "]", "=", "$", "payload", ";", "}", "}", "return", "$", "this", "->", "writeManifest", "(", "$", "manifest", ")", ";", "}" ]
Compile a new plugin manifest. @param array $directories @throws Exception @return array
[ "Compile", "a", "new", "plugin", "manifest", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginsRepository.php#L79-L94
train
themosis/framework
src/Core/PluginsRepository.php
PluginsRepository.getPlugin
public function getPlugin(string $directory) { $files = $this->files->files($this->app->mupluginsPath($directory)); foreach ($files as $file) { $headers = $this->headers($file->getRealPath(), $this->headers); if (! empty($headers['name'])) { return array_merge(['root' => $file->getFilename()], $headers); break; } } }
php
public function getPlugin(string $directory) { $files = $this->files->files($this->app->mupluginsPath($directory)); foreach ($files as $file) { $headers = $this->headers($file->getRealPath(), $this->headers); if (! empty($headers['name'])) { return array_merge(['root' => $file->getFilename()], $headers); break; } } }
[ "public", "function", "getPlugin", "(", "string", "$", "directory", ")", "{", "$", "files", "=", "$", "this", "->", "files", "->", "files", "(", "$", "this", "->", "app", "->", "mupluginsPath", "(", "$", "directory", ")", ")", ";", "foreach", "(", "$", "files", "as", "$", "file", ")", "{", "$", "headers", "=", "$", "this", "->", "headers", "(", "$", "file", "->", "getRealPath", "(", ")", ",", "$", "this", "->", "headers", ")", ";", "if", "(", "!", "empty", "(", "$", "headers", "[", "'name'", "]", ")", ")", "{", "return", "array_merge", "(", "[", "'root'", "=>", "$", "file", "->", "getFilename", "(", ")", "]", ",", "$", "headers", ")", ";", "break", ";", "}", "}", "}" ]
Get the plugin. Find the root file and return its headers. @param string $directory @return array
[ "Get", "the", "plugin", ".", "Find", "the", "root", "file", "and", "return", "its", "headers", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginsRepository.php#L103-L115
train
themosis/framework
src/Core/PluginsRepository.php
PluginsRepository.loadManifest
public function loadManifest() { if ($this->files->exists($this->manifestPath)) { return $this->files->getRequire($this->manifestPath); } return null; }
php
public function loadManifest() { if ($this->files->exists($this->manifestPath)) { return $this->files->getRequire($this->manifestPath); } return null; }
[ "public", "function", "loadManifest", "(", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "this", "->", "manifestPath", ")", ")", "{", "return", "$", "this", "->", "files", "->", "getRequire", "(", "$", "this", "->", "manifestPath", ")", ";", "}", "return", "null", ";", "}" ]
Return plugins manifest. @throws \Illuminate\Contracts\Filesystem\FileNotFoundException @return array|null
[ "Return", "plugins", "manifest", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginsRepository.php#L137-L144
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.load
public function load(string $path): ThemeManager { $this->setThemeDirectory(); $this->setThemeConstants(); $this->loadThemeConfiguration($path); $this->setThemeAutoloading(); return $this; }
php
public function load(string $path): ThemeManager { $this->setThemeDirectory(); $this->setThemeConstants(); $this->loadThemeConfiguration($path); $this->setThemeAutoloading(); return $this; }
[ "public", "function", "load", "(", "string", "$", "path", ")", ":", "ThemeManager", "{", "$", "this", "->", "setThemeDirectory", "(", ")", ";", "$", "this", "->", "setThemeConstants", "(", ")", ";", "$", "this", "->", "loadThemeConfiguration", "(", "$", "path", ")", ";", "$", "this", "->", "setThemeAutoloading", "(", ")", ";", "return", "$", "this", ";", "}" ]
Load the theme. Setup theme requirements. @param string $path Theme configuration folder path. @return $this
[ "Load", "the", "theme", ".", "Setup", "theme", "requirements", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L96-L104
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.assets
public function assets(array $locations) { $finder = $this->app->bound('asset.finder') ? $this->app['asset.finder'] : null; if (! is_null($finder)) { /** @var Finder $finder */ $finder->addLocations($locations); } return $this; }
php
public function assets(array $locations) { $finder = $this->app->bound('asset.finder') ? $this->app['asset.finder'] : null; if (! is_null($finder)) { /** @var Finder $finder */ $finder->addLocations($locations); } return $this; }
[ "public", "function", "assets", "(", "array", "$", "locations", ")", "{", "$", "finder", "=", "$", "this", "->", "app", "->", "bound", "(", "'asset.finder'", ")", "?", "$", "this", "->", "app", "[", "'asset.finder'", "]", ":", "null", ";", "if", "(", "!", "is_null", "(", "$", "finder", ")", ")", "{", "/** @var Finder $finder */", "$", "finder", "->", "addLocations", "(", "$", "locations", ")", ";", "}", "return", "$", "this", ";", "}" ]
Define theme assets directories. @param array $locations @return $this
[ "Define", "theme", "assets", "directories", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L113-L123
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.getUrl
public function getUrl(string $path = '') { if (is_multisite() && defined(SUBDOMAIN_INSTALL) && SUBDOMAIN_INSTALL) { return sprintf( '%s/%s/themes/%s', get_home_url(), CONTENT_DIR, $this->getDirectory() ).($path ? '/'.$path : $path); } return get_template_directory_uri().($path ? '/'.$path : $path); }
php
public function getUrl(string $path = '') { if (is_multisite() && defined(SUBDOMAIN_INSTALL) && SUBDOMAIN_INSTALL) { return sprintf( '%s/%s/themes/%s', get_home_url(), CONTENT_DIR, $this->getDirectory() ).($path ? '/'.$path : $path); } return get_template_directory_uri().($path ? '/'.$path : $path); }
[ "public", "function", "getUrl", "(", "string", "$", "path", "=", "''", ")", "{", "if", "(", "is_multisite", "(", ")", "&&", "defined", "(", "SUBDOMAIN_INSTALL", ")", "&&", "SUBDOMAIN_INSTALL", ")", "{", "return", "sprintf", "(", "'%s/%s/themes/%s'", ",", "get_home_url", "(", ")", ",", "CONTENT_DIR", ",", "$", "this", "->", "getDirectory", "(", ")", ")", ".", "(", "$", "path", "?", "'/'", ".", "$", "path", ":", "$", "path", ")", ";", "}", "return", "get_template_directory_uri", "(", ")", ".", "(", "$", "path", "?", "'/'", ".", "$", "path", ":", "$", "path", ")", ";", "}" ]
Return the theme root URL. @param string $path Path to append to the theme base URL. @return string
[ "Return", "the", "theme", "root", "URL", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L166-L178
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.setThemeDirectory
protected function setThemeDirectory() { $pos = strrpos($this->dirPath, DIRECTORY_SEPARATOR); $this->directory = substr($this->dirPath, $pos + 1); }
php
protected function setThemeDirectory() { $pos = strrpos($this->dirPath, DIRECTORY_SEPARATOR); $this->directory = substr($this->dirPath, $pos + 1); }
[ "protected", "function", "setThemeDirectory", "(", ")", "{", "$", "pos", "=", "strrpos", "(", "$", "this", "->", "dirPath", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "this", "->", "directory", "=", "substr", "(", "$", "this", "->", "dirPath", ",", "$", "pos", "+", "1", ")", ";", "}" ]
Set the theme directory name property.
[ "Set", "the", "theme", "directory", "name", "property", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L183-L188
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.setThemeAutoloading
protected function setThemeAutoloading() { foreach ($this->config->get('theme.autoloading', []) as $ns => $path) { $path = $this->dirPath.'/'.trim($path, '\/'); $this->loader->addPsr4($ns, $path); } $this->loader->register(); }
php
protected function setThemeAutoloading() { foreach ($this->config->get('theme.autoloading', []) as $ns => $path) { $path = $this->dirPath.'/'.trim($path, '\/'); $this->loader->addPsr4($ns, $path); } $this->loader->register(); }
[ "protected", "function", "setThemeAutoloading", "(", ")", "{", "foreach", "(", "$", "this", "->", "config", "->", "get", "(", "'theme.autoloading'", ",", "[", "]", ")", "as", "$", "ns", "=>", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "dirPath", ".", "'/'", ".", "trim", "(", "$", "path", ",", "'\\/'", ")", ";", "$", "this", "->", "loader", "->", "addPsr4", "(", "$", "ns", ",", "$", "path", ")", ";", "}", "$", "this", "->", "loader", "->", "register", "(", ")", ";", "}" ]
Load theme classes.
[ "Load", "theme", "classes", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L203-L211
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.providers
public function providers(array $providers = []) { foreach ($providers as $provider) { $this->app->register(new $provider($this->app)); } return $this; }
php
public function providers(array $providers = []) { foreach ($providers as $provider) { $this->app->register(new $provider($this->app)); } return $this; }
[ "public", "function", "providers", "(", "array", "$", "providers", "=", "[", "]", ")", "{", "foreach", "(", "$", "providers", "as", "$", "provider", ")", "{", "$", "this", "->", "app", "->", "register", "(", "new", "$", "provider", "(", "$", "this", "->", "app", ")", ")", ";", "}", "return", "$", "this", ";", "}" ]
Register theme services providers. @param array $providers @return $this
[ "Register", "theme", "services", "providers", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L220-L227
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.views
public function views(array $paths = []) { if (! $this->app->has('view')) { return $this; } if (empty($paths)) { return $this; } $factory = $this->app->make('view'); $twigLoader = $this->app->make('twig.loader'); foreach ($paths as $path) { $uri = $this->dirPath.'/'.trim($path, '\/'); $factory->getFinder()->prependLocation($uri); $twigLoader->addPath($uri); } return $this; }
php
public function views(array $paths = []) { if (! $this->app->has('view')) { return $this; } if (empty($paths)) { return $this; } $factory = $this->app->make('view'); $twigLoader = $this->app->make('twig.loader'); foreach ($paths as $path) { $uri = $this->dirPath.'/'.trim($path, '\/'); $factory->getFinder()->prependLocation($uri); $twigLoader->addPath($uri); } return $this; }
[ "public", "function", "views", "(", "array", "$", "paths", "=", "[", "]", ")", "{", "if", "(", "!", "$", "this", "->", "app", "->", "has", "(", "'view'", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "empty", "(", "$", "paths", ")", ")", "{", "return", "$", "this", ";", "}", "$", "factory", "=", "$", "this", "->", "app", "->", "make", "(", "'view'", ")", ";", "$", "twigLoader", "=", "$", "this", "->", "app", "->", "make", "(", "'twig.loader'", ")", ";", "foreach", "(", "$", "paths", "as", "$", "path", ")", "{", "$", "uri", "=", "$", "this", "->", "dirPath", ".", "'/'", ".", "trim", "(", "$", "path", ",", "'\\/'", ")", ";", "$", "factory", "->", "getFinder", "(", ")", "->", "prependLocation", "(", "$", "uri", ")", ";", "$", "twigLoader", "->", "addPath", "(", "$", "uri", ")", ";", "}", "return", "$", "this", ";", "}" ]
Register theme views path. @param array $paths @return $this
[ "Register", "theme", "views", "path", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L236-L256
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.setThemeConstants
protected function setThemeConstants() { $this->parsedHeaders = $this->headers($this->dirPath.'/style.css', $this->headers); // Theme text domain. $textdomain = (isset($this->parsedHeaders['text_domain']) && ! empty($this->parsedHeaders['text_domain'])) ? $this->parsedHeaders['text_domain'] : 'themosis_theme'; defined('THEME_TD') ? THEME_TD : define('THEME_TD', $textdomain); }
php
protected function setThemeConstants() { $this->parsedHeaders = $this->headers($this->dirPath.'/style.css', $this->headers); // Theme text domain. $textdomain = (isset($this->parsedHeaders['text_domain']) && ! empty($this->parsedHeaders['text_domain'])) ? $this->parsedHeaders['text_domain'] : 'themosis_theme'; defined('THEME_TD') ? THEME_TD : define('THEME_TD', $textdomain); }
[ "protected", "function", "setThemeConstants", "(", ")", "{", "$", "this", "->", "parsedHeaders", "=", "$", "this", "->", "headers", "(", "$", "this", "->", "dirPath", ".", "'/style.css'", ",", "$", "this", "->", "headers", ")", ";", "// Theme text domain.", "$", "textdomain", "=", "(", "isset", "(", "$", "this", "->", "parsedHeaders", "[", "'text_domain'", "]", ")", "&&", "!", "empty", "(", "$", "this", "->", "parsedHeaders", "[", "'text_domain'", "]", ")", ")", "?", "$", "this", "->", "parsedHeaders", "[", "'text_domain'", "]", ":", "'themosis_theme'", ";", "defined", "(", "'THEME_TD'", ")", "?", "THEME_TD", ":", "define", "(", "'THEME_TD'", ",", "$", "textdomain", ")", ";", "}" ]
Register theme constants.
[ "Register", "theme", "constants", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L261-L271
train
themosis/framework
src/Core/ThemeManager.php
ThemeManager.sidebars
public function sidebars($sidebars = []) { if (empty($sidebars)) { return $this; } if (function_exists('register_sidebar')) { foreach ($sidebars as $sidebar) { register_sidebar($sidebar); } } return $this; }
php
public function sidebars($sidebars = []) { if (empty($sidebars)) { return $this; } if (function_exists('register_sidebar')) { foreach ($sidebars as $sidebar) { register_sidebar($sidebar); } } return $this; }
[ "public", "function", "sidebars", "(", "$", "sidebars", "=", "[", "]", ")", "{", "if", "(", "empty", "(", "$", "sidebars", ")", ")", "{", "return", "$", "this", ";", "}", "if", "(", "function_exists", "(", "'register_sidebar'", ")", ")", "{", "foreach", "(", "$", "sidebars", "as", "$", "sidebar", ")", "{", "register_sidebar", "(", "$", "sidebar", ")", ";", "}", "}", "return", "$", "this", ";", "}" ]
Register theme sidebars. @param array $sidebars @return $this
[ "Register", "theme", "sidebars", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/ThemeManager.php#L342-L355
train
themosis/framework
src/Hook/ActionBuilder.php
ActionBuilder.run
public function run($hook, $args = null) { if (is_array($args)) { $this->doActionRefArray($hook, $args); } else { $this->doAction($hook, $args); } return $this; }
php
public function run($hook, $args = null) { if (is_array($args)) { $this->doActionRefArray($hook, $args); } else { $this->doAction($hook, $args); } return $this; }
[ "public", "function", "run", "(", "$", "hook", ",", "$", "args", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "args", ")", ")", "{", "$", "this", "->", "doActionRefArray", "(", "$", "hook", ",", "$", "args", ")", ";", "}", "else", "{", "$", "this", "->", "doAction", "(", "$", "hook", ",", "$", "args", ")", ";", "}", "return", "$", "this", ";", "}" ]
Run all actions registered with the hook. @param string $hook The action hook name. @param mixed $args @return $this
[ "Run", "all", "actions", "registered", "with", "the", "hook", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Hook/ActionBuilder.php#L15-L24
train
themosis/framework
src/Hook/ActionBuilder.php
ActionBuilder.addEventListener
protected function addEventListener($name, $callback, $priority, $accepted_args) { $this->hooks[$name] = [$callback, $priority, $accepted_args]; $this->addAction($name, $callback, $priority, $accepted_args); }
php
protected function addEventListener($name, $callback, $priority, $accepted_args) { $this->hooks[$name] = [$callback, $priority, $accepted_args]; $this->addAction($name, $callback, $priority, $accepted_args); }
[ "protected", "function", "addEventListener", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", "{", "$", "this", "->", "hooks", "[", "$", "name", "]", "=", "[", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", "]", ";", "$", "this", "->", "addAction", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", ";", "}" ]
Add an action event for the specified hook. @param string $name @param \Closure|string|array $callback @param int $priority @param int $accepted_args
[ "Add", "an", "action", "event", "for", "the", "specified", "hook", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Hook/ActionBuilder.php#L56-L60
train
themosis/framework
src/Hook/ActionBuilder.php
ActionBuilder.addAction
protected function addAction($name, $callback, $priority, $accepted_args) { add_action($name, $callback, $priority, $accepted_args); }
php
protected function addAction($name, $callback, $priority, $accepted_args) { add_action($name, $callback, $priority, $accepted_args); }
[ "protected", "function", "addAction", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", "{", "add_action", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", ";", "}" ]
Calls the WordPress add_action function to listen on a hook event. @param string $name @param \Closure|string|array $callback @param int $priority @param int $accepted_args
[ "Calls", "the", "WordPress", "add_action", "function", "to", "listen", "on", "a", "hook", "event", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Hook/ActionBuilder.php#L70-L73
train
themosis/framework
src/Core/EnvironmentDetector.php
EnvironmentDetector.detectConsoleEnvironment
protected function detectConsoleEnvironment(Closure $callback, array $args) { if (! is_null($value = $this->getEnvironmentArgument($args))) { return head(array_slice(explode('=', $value), 1)); } return $this->detectWebEnvironment($callback); }
php
protected function detectConsoleEnvironment(Closure $callback, array $args) { if (! is_null($value = $this->getEnvironmentArgument($args))) { return head(array_slice(explode('=', $value), 1)); } return $this->detectWebEnvironment($callback); }
[ "protected", "function", "detectConsoleEnvironment", "(", "Closure", "$", "callback", ",", "array", "$", "args", ")", "{", "if", "(", "!", "is_null", "(", "$", "value", "=", "$", "this", "->", "getEnvironmentArgument", "(", "$", "args", ")", ")", ")", "{", "return", "head", "(", "array_slice", "(", "explode", "(", "'='", ",", "$", "value", ")", ",", "1", ")", ")", ";", "}", "return", "$", "this", "->", "detectWebEnvironment", "(", "$", "callback", ")", ";", "}" ]
Set the application environment for a command-line request. @param Closure $callback @param array $args @return string
[ "Set", "the", "application", "environment", "for", "a", "command", "-", "line", "request", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/EnvironmentDetector.php#L48-L55
train
themosis/framework
src/PostType/Factory.php
Factory.make
public function make(string $slug, string $plural, string $singular): PostTypeInterface { $postType = (new PostType($slug, $this->action, $this->filter)) ->setLabels([ 'name' => $plural, 'singular_name' => $singular, 'add_new_item' => sprintf('Add New %s', $singular), 'edit_item' => sprintf('Edit %s', $singular), 'new_item' => sprintf('New %s', $singular), 'view_item' => sprintf('View %s', $singular), 'view_items' => sprintf('View %s', $plural), 'search_items' => sprintf('Search %s', $plural), 'not_found' => sprintf('No %s found', $plural), 'not_found_in_trash' => sprintf('No %s found in Trash', $plural), 'parent_item_colon' => sprintf('Parent %s:', $singular), 'all_items' => sprintf('All %s', $plural), 'archives' => sprintf('%s Archives', $singular), 'attributes' => sprintf('%s Attributes', $singular), 'insert_into_item' => sprintf('Insert into %s', strtolower($singular)), 'uploaded_to_this_item' => sprintf('Uploaded to this %s', strtolower($singular)), 'filter_items_list' => sprintf('Filter %s list', strtolower($plural)), 'items_list_navigation' => sprintf('%s list navigation', $plural), 'items_list' => sprintf('%s list', $plural) ]) ->setArguments([ 'public' => true, 'show_in_rest' => true, 'menu_position' => 20, 'supports' => ['title'], 'has_archive' => true ]); $abstract = sprintf('themosis.posttype.%s', $slug); if (! $this->container->bound($abstract)) { $this->container->instance($abstract, $postType); } else { throw new PostTypeException('The post type ['.$slug.'] already exists.'); } return $postType; }
php
public function make(string $slug, string $plural, string $singular): PostTypeInterface { $postType = (new PostType($slug, $this->action, $this->filter)) ->setLabels([ 'name' => $plural, 'singular_name' => $singular, 'add_new_item' => sprintf('Add New %s', $singular), 'edit_item' => sprintf('Edit %s', $singular), 'new_item' => sprintf('New %s', $singular), 'view_item' => sprintf('View %s', $singular), 'view_items' => sprintf('View %s', $plural), 'search_items' => sprintf('Search %s', $plural), 'not_found' => sprintf('No %s found', $plural), 'not_found_in_trash' => sprintf('No %s found in Trash', $plural), 'parent_item_colon' => sprintf('Parent %s:', $singular), 'all_items' => sprintf('All %s', $plural), 'archives' => sprintf('%s Archives', $singular), 'attributes' => sprintf('%s Attributes', $singular), 'insert_into_item' => sprintf('Insert into %s', strtolower($singular)), 'uploaded_to_this_item' => sprintf('Uploaded to this %s', strtolower($singular)), 'filter_items_list' => sprintf('Filter %s list', strtolower($plural)), 'items_list_navigation' => sprintf('%s list navigation', $plural), 'items_list' => sprintf('%s list', $plural) ]) ->setArguments([ 'public' => true, 'show_in_rest' => true, 'menu_position' => 20, 'supports' => ['title'], 'has_archive' => true ]); $abstract = sprintf('themosis.posttype.%s', $slug); if (! $this->container->bound($abstract)) { $this->container->instance($abstract, $postType); } else { throw new PostTypeException('The post type ['.$slug.'] already exists.'); } return $postType; }
[ "public", "function", "make", "(", "string", "$", "slug", ",", "string", "$", "plural", ",", "string", "$", "singular", ")", ":", "PostTypeInterface", "{", "$", "postType", "=", "(", "new", "PostType", "(", "$", "slug", ",", "$", "this", "->", "action", ",", "$", "this", "->", "filter", ")", ")", "->", "setLabels", "(", "[", "'name'", "=>", "$", "plural", ",", "'singular_name'", "=>", "$", "singular", ",", "'add_new_item'", "=>", "sprintf", "(", "'Add New %s'", ",", "$", "singular", ")", ",", "'edit_item'", "=>", "sprintf", "(", "'Edit %s'", ",", "$", "singular", ")", ",", "'new_item'", "=>", "sprintf", "(", "'New %s'", ",", "$", "singular", ")", ",", "'view_item'", "=>", "sprintf", "(", "'View %s'", ",", "$", "singular", ")", ",", "'view_items'", "=>", "sprintf", "(", "'View %s'", ",", "$", "plural", ")", ",", "'search_items'", "=>", "sprintf", "(", "'Search %s'", ",", "$", "plural", ")", ",", "'not_found'", "=>", "sprintf", "(", "'No %s found'", ",", "$", "plural", ")", ",", "'not_found_in_trash'", "=>", "sprintf", "(", "'No %s found in Trash'", ",", "$", "plural", ")", ",", "'parent_item_colon'", "=>", "sprintf", "(", "'Parent %s:'", ",", "$", "singular", ")", ",", "'all_items'", "=>", "sprintf", "(", "'All %s'", ",", "$", "plural", ")", ",", "'archives'", "=>", "sprintf", "(", "'%s Archives'", ",", "$", "singular", ")", ",", "'attributes'", "=>", "sprintf", "(", "'%s Attributes'", ",", "$", "singular", ")", ",", "'insert_into_item'", "=>", "sprintf", "(", "'Insert into %s'", ",", "strtolower", "(", "$", "singular", ")", ")", ",", "'uploaded_to_this_item'", "=>", "sprintf", "(", "'Uploaded to this %s'", ",", "strtolower", "(", "$", "singular", ")", ")", ",", "'filter_items_list'", "=>", "sprintf", "(", "'Filter %s list'", ",", "strtolower", "(", "$", "plural", ")", ")", ",", "'items_list_navigation'", "=>", "sprintf", "(", "'%s list navigation'", ",", "$", "plural", ")", ",", "'items_list'", "=>", "sprintf", "(", "'%s list'", ",", "$", "plural", ")", "]", ")", "->", "setArguments", "(", "[", "'public'", "=>", "true", ",", "'show_in_rest'", "=>", "true", ",", "'menu_position'", "=>", "20", ",", "'supports'", "=>", "[", "'title'", "]", ",", "'has_archive'", "=>", "true", "]", ")", ";", "$", "abstract", "=", "sprintf", "(", "'themosis.posttype.%s'", ",", "$", "slug", ")", ";", "if", "(", "!", "$", "this", "->", "container", "->", "bound", "(", "$", "abstract", ")", ")", "{", "$", "this", "->", "container", "->", "instance", "(", "$", "abstract", ",", "$", "postType", ")", ";", "}", "else", "{", "throw", "new", "PostTypeException", "(", "'The post type ['", ".", "$", "slug", ".", "'] already exists.'", ")", ";", "}", "return", "$", "postType", ";", "}" ]
Create a new post type instance. @param string $slug @param string $plural @param string $singular @throws PostTypeException @return PostTypeInterface
[ "Create", "a", "new", "post", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/PostType/Factory.php#L44-L85
train
themosis/framework
src/Core/Console/Kernel.php
Kernel.command
public function command($signature, \Closure $callback) { $command = new ClosureCommand($signature, $callback); Console::starting(function ($console) use ($command) { $console->add($command); }); return $command; }
php
public function command($signature, \Closure $callback) { $command = new ClosureCommand($signature, $callback); Console::starting(function ($console) use ($command) { $console->add($command); }); return $command; }
[ "public", "function", "command", "(", "$", "signature", ",", "\\", "Closure", "$", "callback", ")", "{", "$", "command", "=", "new", "ClosureCommand", "(", "$", "signature", ",", "$", "callback", ")", ";", "Console", "::", "starting", "(", "function", "(", "$", "console", ")", "use", "(", "$", "command", ")", "{", "$", "console", "->", "add", "(", "$", "command", ")", ";", "}", ")", ";", "return", "$", "command", ";", "}" ]
Register a closure based command with the application. @param string $signature @param \Closure $callback @return ClosureCommand
[ "Register", "a", "closure", "based", "command", "with", "the", "application", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Console/Kernel.php#L176-L185
train
themosis/framework
src/Core/Console/Kernel.php
Kernel.getConsole
protected function getConsole() { if (is_null($this->console)) { $console = new Console($this->app, $this->events, $this->app->version()); $console->setName('Themosis Framework'); return $this->console = $console->resolveCommands($this->commands); } return $this->console; }
php
protected function getConsole() { if (is_null($this->console)) { $console = new Console($this->app, $this->events, $this->app->version()); $console->setName('Themosis Framework'); return $this->console = $console->resolveCommands($this->commands); } return $this->console; }
[ "protected", "function", "getConsole", "(", ")", "{", "if", "(", "is_null", "(", "$", "this", "->", "console", ")", ")", "{", "$", "console", "=", "new", "Console", "(", "$", "this", "->", "app", ",", "$", "this", "->", "events", ",", "$", "this", "->", "app", "->", "version", "(", ")", ")", ";", "$", "console", "->", "setName", "(", "'Themosis Framework'", ")", ";", "return", "$", "this", "->", "console", "=", "$", "console", "->", "resolveCommands", "(", "$", "this", "->", "commands", ")", ";", "}", "return", "$", "this", "->", "console", ";", "}" ]
Return the console application instance. @return \Illuminate\Console\Application
[ "Return", "the", "console", "application", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Console/Kernel.php#L256-L266
train
themosis/framework
src/Core/Console/Kernel.php
Kernel.call
public function call($command, array $parameters = [], $outputBuffer = null) { $this->bootstrap(); return $this->getConsole()->call($command, $parameters, $outputBuffer); }
php
public function call($command, array $parameters = [], $outputBuffer = null) { $this->bootstrap(); return $this->getConsole()->call($command, $parameters, $outputBuffer); }
[ "public", "function", "call", "(", "$", "command", ",", "array", "$", "parameters", "=", "[", "]", ",", "$", "outputBuffer", "=", "null", ")", "{", "$", "this", "->", "bootstrap", "(", ")", ";", "return", "$", "this", "->", "getConsole", "(", ")", "->", "call", "(", "$", "command", ",", "$", "parameters", ",", "$", "outputBuffer", ")", ";", "}" ]
Run a console command by name. @param string $command @param array $parameters @param OutputInterface $outputBuffer @return int
[ "Run", "a", "console", "command", "by", "name", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Console/Kernel.php#L297-L302
train
themosis/framework
src/Core/Console/Kernel.php
Kernel.renderException
protected function renderException($output, \Exception $e) { $this->app[ExceptionHandler::class]->renderForConsole($output, $e); }
php
protected function renderException($output, \Exception $e) { $this->app[ExceptionHandler::class]->renderForConsole($output, $e); }
[ "protected", "function", "renderException", "(", "$", "output", ",", "\\", "Exception", "$", "e", ")", "{", "$", "this", "->", "app", "[", "ExceptionHandler", "::", "class", "]", "->", "renderForConsole", "(", "$", "output", ",", "$", "e", ")", ";", "}" ]
Render the exception. @param OutputInterface $output @param \Exception $e
[ "Render", "the", "exception", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Console/Kernel.php#L357-L360
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.setLayout
protected function setLayout($expanded = false, $multiple = false) { if ($expanded && false === $multiple) { $this->layout = 'radio'; } elseif ($expanded && $multiple) { $this->layout = 'checkbox'; } return $this; }
php
protected function setLayout($expanded = false, $multiple = false) { if ($expanded && false === $multiple) { $this->layout = 'radio'; } elseif ($expanded && $multiple) { $this->layout = 'checkbox'; } return $this; }
[ "protected", "function", "setLayout", "(", "$", "expanded", "=", "false", ",", "$", "multiple", "=", "false", ")", "{", "if", "(", "$", "expanded", "&&", "false", "===", "$", "multiple", ")", "{", "$", "this", "->", "layout", "=", "'radio'", ";", "}", "elseif", "(", "$", "expanded", "&&", "$", "multiple", ")", "{", "$", "this", "->", "layout", "=", "'checkbox'", ";", "}", "return", "$", "this", ";", "}" ]
Set the field layout option. @param bool $expanded @param bool $multiple @return $this
[ "Set", "the", "field", "layout", "option", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L148-L157
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.getOptions
public function getOptions(array $excludes = null): array { $options = parent::getOptions($excludes); /* * Let's add the choices in a readable format as * well as the layout property. */ $choices = $this->getOption('choices', []); if ($choices instanceof ChoiceListInterface) { $choices = $choices->format()->get(); } return array_merge($options, [ 'choices' => $choices, 'layout' => $this->getLayout() ]); }
php
public function getOptions(array $excludes = null): array { $options = parent::getOptions($excludes); /* * Let's add the choices in a readable format as * well as the layout property. */ $choices = $this->getOption('choices', []); if ($choices instanceof ChoiceListInterface) { $choices = $choices->format()->get(); } return array_merge($options, [ 'choices' => $choices, 'layout' => $this->getLayout() ]); }
[ "public", "function", "getOptions", "(", "array", "$", "excludes", "=", "null", ")", ":", "array", "{", "$", "options", "=", "parent", "::", "getOptions", "(", "$", "excludes", ")", ";", "/*\n * Let's add the choices in a readable format as\n * well as the layout property.\n */", "$", "choices", "=", "$", "this", "->", "getOption", "(", "'choices'", ",", "[", "]", ")", ";", "if", "(", "$", "choices", "instanceof", "ChoiceListInterface", ")", "{", "$", "choices", "=", "$", "choices", "->", "format", "(", ")", "->", "get", "(", ")", ";", "}", "return", "array_merge", "(", "$", "options", ",", "[", "'choices'", "=>", "$", "choices", ",", "'layout'", "=>", "$", "this", "->", "getLayout", "(", ")", "]", ")", ";", "}" ]
Return choice type field options. @param array|null $excludes @return array
[ "Return", "choice", "type", "field", "options", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L166-L184
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.metaboxSave
public function metaboxSave($value, int $post_id) { $this->setValue($value); if (! $this->getOption('multiple', false)) { // Store single value. $this->saveSingleValue($this->getRawValue(), $post_id); } else { // Store multiple values. $this->saveMultipleValue($this->getRawValue(), $post_id); } }
php
public function metaboxSave($value, int $post_id) { $this->setValue($value); if (! $this->getOption('multiple', false)) { // Store single value. $this->saveSingleValue($this->getRawValue(), $post_id); } else { // Store multiple values. $this->saveMultipleValue($this->getRawValue(), $post_id); } }
[ "public", "function", "metaboxSave", "(", "$", "value", ",", "int", "$", "post_id", ")", "{", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "if", "(", "!", "$", "this", "->", "getOption", "(", "'multiple'", ",", "false", ")", ")", "{", "// Store single value.", "$", "this", "->", "saveSingleValue", "(", "$", "this", "->", "getRawValue", "(", ")", ",", "$", "post_id", ")", ";", "}", "else", "{", "// Store multiple values.", "$", "this", "->", "saveMultipleValue", "(", "$", "this", "->", "getRawValue", "(", ")", ",", "$", "post_id", ")", ";", "}", "}" ]
Handle metabox field value registration. @param string|array $value @param int $post_id
[ "Handle", "metabox", "field", "value", "registration", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L228-L239
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.metaboxGet
public function metaboxGet(int $post_id) { $value = get_post_meta($post_id, $this->getName(), ! $this->getOption('multiple', false)); if (! empty($value)) { $this->setValue($value); } }
php
public function metaboxGet(int $post_id) { $value = get_post_meta($post_id, $this->getName(), ! $this->getOption('multiple', false)); if (! empty($value)) { $this->setValue($value); } }
[ "public", "function", "metaboxGet", "(", "int", "$", "post_id", ")", "{", "$", "value", "=", "get_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ",", "!", "$", "this", "->", "getOption", "(", "'multiple'", ",", "false", ")", ")", ";", "if", "(", "!", "empty", "(", "$", "value", ")", ")", "{", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "}", "}" ]
Initialize metabox field value. @param int $post_id
[ "Initialize", "metabox", "field", "value", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L246-L253
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.saveSingleValue
protected function saveSingleValue($value, int $post_id) { $previous = get_post_meta($post_id, $this->getName(), true); if (is_null($value) || empty($value)) { delete_post_meta($post_id, $this->getName()); } elseif (empty($previous)) { add_post_meta($post_id, $this->getName(), $value, true); } else { update_post_meta($post_id, $this->getName(), $value, $previous); } }
php
protected function saveSingleValue($value, int $post_id) { $previous = get_post_meta($post_id, $this->getName(), true); if (is_null($value) || empty($value)) { delete_post_meta($post_id, $this->getName()); } elseif (empty($previous)) { add_post_meta($post_id, $this->getName(), $value, true); } else { update_post_meta($post_id, $this->getName(), $value, $previous); } }
[ "protected", "function", "saveSingleValue", "(", "$", "value", ",", "int", "$", "post_id", ")", "{", "$", "previous", "=", "get_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "delete_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "empty", "(", "$", "previous", ")", ")", "{", "add_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "value", ",", "true", ")", ";", "}", "else", "{", "update_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "value", ",", "$", "previous", ")", ";", "}", "}" ]
Save a single value. @param string $value @param int $post_id
[ "Save", "a", "single", "value", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L261-L272
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.saveTermSingleValue
protected function saveTermSingleValue($value, int $term_id) { $previous = get_term_meta($term_id, $this->getName(), true); if (is_null($value) || empty($value)) { delete_term_meta($term_id, $this->getName()); } elseif (empty($previous)) { add_term_meta($term_id, $this->getName(), $value, true); } else { update_term_meta($term_id, $this->getName(), $value, $previous); } }
php
protected function saveTermSingleValue($value, int $term_id) { $previous = get_term_meta($term_id, $this->getName(), true); if (is_null($value) || empty($value)) { delete_term_meta($term_id, $this->getName()); } elseif (empty($previous)) { add_term_meta($term_id, $this->getName(), $value, true); } else { update_term_meta($term_id, $this->getName(), $value, $previous); } }
[ "protected", "function", "saveTermSingleValue", "(", "$", "value", ",", "int", "$", "term_id", ")", "{", "$", "previous", "=", "get_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "delete_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "empty", "(", "$", "previous", ")", ")", "{", "add_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "value", ",", "true", ")", ";", "}", "else", "{", "update_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "value", ",", "$", "previous", ")", ";", "}", "}" ]
Handle field single term meta registration. @param string $value @param int $term_id
[ "Handle", "field", "single", "term", "meta", "registration", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L322-L333
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.saveTermMultipleValue
protected function saveTermMultipleValue($value, int $term_id) { $previous = get_term_meta($term_id, $this->getName(), false); if (is_null($value) || empty($value)) { delete_term_meta($term_id, $this->getName()); } elseif (empty($previous) && is_array($value)) { array_walk($value, function ($val) use ($term_id) { add_term_meta($term_id, $this->getName(), $val, false); }); } else { delete_term_meta($term_id, $this->getName()); array_walk($value, function ($val) use ($term_id) { add_term_meta($term_id, $this->getName(), $val, false); }); } }
php
protected function saveTermMultipleValue($value, int $term_id) { $previous = get_term_meta($term_id, $this->getName(), false); if (is_null($value) || empty($value)) { delete_term_meta($term_id, $this->getName()); } elseif (empty($previous) && is_array($value)) { array_walk($value, function ($val) use ($term_id) { add_term_meta($term_id, $this->getName(), $val, false); }); } else { delete_term_meta($term_id, $this->getName()); array_walk($value, function ($val) use ($term_id) { add_term_meta($term_id, $this->getName(), $val, false); }); } }
[ "protected", "function", "saveTermMultipleValue", "(", "$", "value", ",", "int", "$", "term_id", ")", "{", "$", "previous", "=", "get_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ",", "false", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "delete_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "empty", "(", "$", "previous", ")", "&&", "is_array", "(", "$", "value", ")", ")", "{", "array_walk", "(", "$", "value", ",", "function", "(", "$", "val", ")", "use", "(", "$", "term_id", ")", "{", "add_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "val", ",", "false", ")", ";", "}", ")", ";", "}", "else", "{", "delete_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "array_walk", "(", "$", "value", ",", "function", "(", "$", "val", ")", "use", "(", "$", "term_id", ")", "{", "add_term_meta", "(", "$", "term_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "val", ",", "false", ")", ";", "}", ")", ";", "}", "}" ]
Handle field multiple term meta registration. @param $value @param int $term_id
[ "Handle", "field", "multiple", "term", "meta", "registration", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L341-L358
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.saveUserSingleValue
protected function saveUserSingleValue($value, int $user_id) { $previous = get_user_meta($user_id, $this->getName(), true); if (is_null($value) || empty($value)) { delete_user_meta($user_id, $this->getName()); } elseif (empty($previous)) { add_user_meta($user_id, $this->getName(), $value, true); } else { update_user_meta($user_id, $this->getName(), $value, $previous); } }
php
protected function saveUserSingleValue($value, int $user_id) { $previous = get_user_meta($user_id, $this->getName(), true); if (is_null($value) || empty($value)) { delete_user_meta($user_id, $this->getName()); } elseif (empty($previous)) { add_user_meta($user_id, $this->getName(), $value, true); } else { update_user_meta($user_id, $this->getName(), $value, $previous); } }
[ "protected", "function", "saveUserSingleValue", "(", "$", "value", ",", "int", "$", "user_id", ")", "{", "$", "previous", "=", "get_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "delete_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "empty", "(", "$", "previous", ")", ")", "{", "add_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "value", ",", "true", ")", ";", "}", "else", "{", "update_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "value", ",", "$", "previous", ")", ";", "}", "}" ]
Handle field user meta single data registration. @param string $value @param int $user_id
[ "Handle", "field", "user", "meta", "single", "data", "registration", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L411-L422
train
themosis/framework
src/Forms/Fields/Types/ChoiceType.php
ChoiceType.saveUserMultipleValue
protected function saveUserMultipleValue($value, int $user_id) { $previous = get_user_meta($user_id, $this->getName(), false); if (is_null($value) || empty($value)) { delete_user_meta($user_id, $this->getName()); } elseif (empty($previous) && is_array($value)) { array_walk($value, function ($val) use ($user_id) { add_user_meta($user_id, $this->getName(), $val, false); }); } else { delete_user_meta($user_id, $this->getName()); array_walk($value, function ($val) use ($user_id) { add_user_meta($user_id, $this->getName(), $val, false); }); } }
php
protected function saveUserMultipleValue($value, int $user_id) { $previous = get_user_meta($user_id, $this->getName(), false); if (is_null($value) || empty($value)) { delete_user_meta($user_id, $this->getName()); } elseif (empty($previous) && is_array($value)) { array_walk($value, function ($val) use ($user_id) { add_user_meta($user_id, $this->getName(), $val, false); }); } else { delete_user_meta($user_id, $this->getName()); array_walk($value, function ($val) use ($user_id) { add_user_meta($user_id, $this->getName(), $val, false); }); } }
[ "protected", "function", "saveUserMultipleValue", "(", "$", "value", ",", "int", "$", "user_id", ")", "{", "$", "previous", "=", "get_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ",", "false", ")", ";", "if", "(", "is_null", "(", "$", "value", ")", "||", "empty", "(", "$", "value", ")", ")", "{", "delete_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "empty", "(", "$", "previous", ")", "&&", "is_array", "(", "$", "value", ")", ")", "{", "array_walk", "(", "$", "value", ",", "function", "(", "$", "val", ")", "use", "(", "$", "user_id", ")", "{", "add_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "val", ",", "false", ")", ";", "}", ")", ";", "}", "else", "{", "delete_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "array_walk", "(", "$", "value", ",", "function", "(", "$", "val", ")", "use", "(", "$", "user_id", ")", "{", "add_user_meta", "(", "$", "user_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "val", ",", "false", ")", ";", "}", ")", ";", "}", "}" ]
Handle field user meta multiple data registration. @param array $value @param int $user_id
[ "Handle", "field", "user", "meta", "multiple", "data", "registration", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/ChoiceType.php#L430-L447
train
themosis/framework
src/Metabox/Resources/Transformers/MetaboxTransformer.php
MetaboxTransformer.transform
public function transform(MetaboxInterface $metabox) { return [ 'id' => $metabox->getId(), 'context' => $metabox->getContext(), 'l10n' => $metabox->getTranslations(), 'locale' => $metabox->getLocale(), 'priority' => $metabox->getPriority(), 'screen' => $this->getScreen($metabox->getScreen()), 'title' => $metabox->getTitle(), ]; }
php
public function transform(MetaboxInterface $metabox) { return [ 'id' => $metabox->getId(), 'context' => $metabox->getContext(), 'l10n' => $metabox->getTranslations(), 'locale' => $metabox->getLocale(), 'priority' => $metabox->getPriority(), 'screen' => $this->getScreen($metabox->getScreen()), 'title' => $metabox->getTitle(), ]; }
[ "public", "function", "transform", "(", "MetaboxInterface", "$", "metabox", ")", "{", "return", "[", "'id'", "=>", "$", "metabox", "->", "getId", "(", ")", ",", "'context'", "=>", "$", "metabox", "->", "getContext", "(", ")", ",", "'l10n'", "=>", "$", "metabox", "->", "getTranslations", "(", ")", ",", "'locale'", "=>", "$", "metabox", "->", "getLocale", "(", ")", ",", "'priority'", "=>", "$", "metabox", "->", "getPriority", "(", ")", ",", "'screen'", "=>", "$", "this", "->", "getScreen", "(", "$", "metabox", "->", "getScreen", "(", ")", ")", ",", "'title'", "=>", "$", "metabox", "->", "getTitle", "(", ")", ",", "]", ";", "}" ]
Transform the metabox to a resource. @param MetaboxInterface $metabox @return array
[ "Transform", "the", "metabox", "to", "a", "resource", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Metabox/Resources/Transformers/MetaboxTransformer.php#L29-L40
train
themosis/framework
src/Metabox/Resources/Transformers/MetaboxTransformer.php
MetaboxTransformer.getScreen
protected function getScreen($screen) { if (is_string($screen) && function_exists('convert_to_screen')) { $screen = convert_to_screen($screen); } if ($screen instanceof \WP_Screen) { return [ 'id' => $screen->id, 'post_type' => $screen->post_type ]; } // Screen is still a string. return [ 'id' => $screen, 'post_type' => $screen ]; }
php
protected function getScreen($screen) { if (is_string($screen) && function_exists('convert_to_screen')) { $screen = convert_to_screen($screen); } if ($screen instanceof \WP_Screen) { return [ 'id' => $screen->id, 'post_type' => $screen->post_type ]; } // Screen is still a string. return [ 'id' => $screen, 'post_type' => $screen ]; }
[ "protected", "function", "getScreen", "(", "$", "screen", ")", "{", "if", "(", "is_string", "(", "$", "screen", ")", "&&", "function_exists", "(", "'convert_to_screen'", ")", ")", "{", "$", "screen", "=", "convert_to_screen", "(", "$", "screen", ")", ";", "}", "if", "(", "$", "screen", "instanceof", "\\", "WP_Screen", ")", "{", "return", "[", "'id'", "=>", "$", "screen", "->", "id", ",", "'post_type'", "=>", "$", "screen", "->", "post_type", "]", ";", "}", "// Screen is still a string.", "return", "[", "'id'", "=>", "$", "screen", ",", "'post_type'", "=>", "$", "screen", "]", ";", "}" ]
Get the metabox screen data. @param $screen @return array
[ "Get", "the", "metabox", "screen", "data", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Metabox/Resources/Transformers/MetaboxTransformer.php#L49-L67
train
themosis/framework
src/Metabox/Resources/Transformers/MetaboxTransformer.php
MetaboxTransformer.includeFields
public function includeFields(MetaboxInterface $metabox) { return $this->collection( $metabox->repository()->all(), function (FieldTypeInterface $field) { $field = $field->setResourceTransformerFactory(new Factory()); $transformer = $field->getResourceTransformerFactory()->make($field->getResourceTransformer()); /** @var FieldTransformer $transformer */ return $transformer->transform($field); } ); }
php
public function includeFields(MetaboxInterface $metabox) { return $this->collection( $metabox->repository()->all(), function (FieldTypeInterface $field) { $field = $field->setResourceTransformerFactory(new Factory()); $transformer = $field->getResourceTransformerFactory()->make($field->getResourceTransformer()); /** @var FieldTransformer $transformer */ return $transformer->transform($field); } ); }
[ "public", "function", "includeFields", "(", "MetaboxInterface", "$", "metabox", ")", "{", "return", "$", "this", "->", "collection", "(", "$", "metabox", "->", "repository", "(", ")", "->", "all", "(", ")", ",", "function", "(", "FieldTypeInterface", "$", "field", ")", "{", "$", "field", "=", "$", "field", "->", "setResourceTransformerFactory", "(", "new", "Factory", "(", ")", ")", ";", "$", "transformer", "=", "$", "field", "->", "getResourceTransformerFactory", "(", ")", "->", "make", "(", "$", "field", "->", "getResourceTransformer", "(", ")", ")", ";", "/** @var FieldTransformer $transformer */", "return", "$", "transformer", "->", "transform", "(", "$", "field", ")", ";", "}", ")", ";", "}" ]
Return the metabox fields. @param MetaboxInterface $metabox @return \League\Fractal\Resource\Collection
[ "Return", "the", "metabox", "fields", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Metabox/Resources/Transformers/MetaboxTransformer.php#L76-L88
train
themosis/framework
src/Forms/Transformers/StringToBooleanTransformer.php
StringToBooleanTransformer.transform
public function transform($data) { if (is_null($data)) { return false; } if (! is_string($data)) { throw new DataTransformerException('A string value is expected.'); } if (empty($data)) { return false; } if (in_array($data, ['off', 'no'], true)) { return false; } return true; }
php
public function transform($data) { if (is_null($data)) { return false; } if (! is_string($data)) { throw new DataTransformerException('A string value is expected.'); } if (empty($data)) { return false; } if (in_array($data, ['off', 'no'], true)) { return false; } return true; }
[ "public", "function", "transform", "(", "$", "data", ")", "{", "if", "(", "is_null", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "if", "(", "!", "is_string", "(", "$", "data", ")", ")", "{", "throw", "new", "DataTransformerException", "(", "'A string value is expected.'", ")", ";", "}", "if", "(", "empty", "(", "$", "data", ")", ")", "{", "return", "false", ";", "}", "if", "(", "in_array", "(", "$", "data", ",", "[", "'off'", ",", "'no'", "]", ",", "true", ")", ")", "{", "return", "false", ";", "}", "return", "true", ";", "}" ]
Convert a string to a boolean value. @param string $data @throws DataTransformerException @return bool
[ "Convert", "a", "string", "to", "a", "boolean", "value", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Transformers/StringToBooleanTransformer.php#L19-L38
train
themosis/framework
src/Asset/File.php
File.setType
public function setType(string $filename, $type = null): AssetFileInterface { if (! is_null($type) && in_array($type, $this->extensions, true)) { // We first listen to a defined asset type. // If no type is defined, let's try to discover it. $this->type = $this->findType($type); return $this; } $ext = $this->files->extension($filename); if (! empty($ext) && in_array($ext, $this->extensions, true)) { $this->type = $this->findType($ext); } return $this; }
php
public function setType(string $filename, $type = null): AssetFileInterface { if (! is_null($type) && in_array($type, $this->extensions, true)) { // We first listen to a defined asset type. // If no type is defined, let's try to discover it. $this->type = $this->findType($type); return $this; } $ext = $this->files->extension($filename); if (! empty($ext) && in_array($ext, $this->extensions, true)) { $this->type = $this->findType($ext); } return $this; }
[ "public", "function", "setType", "(", "string", "$", "filename", ",", "$", "type", "=", "null", ")", ":", "AssetFileInterface", "{", "if", "(", "!", "is_null", "(", "$", "type", ")", "&&", "in_array", "(", "$", "type", ",", "$", "this", "->", "extensions", ",", "true", ")", ")", "{", "// We first listen to a defined asset type.", "// If no type is defined, let's try to discover it.", "$", "this", "->", "type", "=", "$", "this", "->", "findType", "(", "$", "type", ")", ";", "return", "$", "this", ";", "}", "$", "ext", "=", "$", "this", "->", "files", "->", "extension", "(", "$", "filename", ")", ";", "if", "(", "!", "empty", "(", "$", "ext", ")", "&&", "in_array", "(", "$", "ext", ",", "$", "this", "->", "extensions", ",", "true", ")", ")", "{", "$", "this", "->", "type", "=", "$", "this", "->", "findType", "(", "$", "ext", ")", ";", "}", "return", "$", "this", ";", "}" ]
Set the asset file type. @param string $filename @param string $type @return AssetFileInterface
[ "Set", "the", "asset", "file", "type", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Asset/File.php#L131-L148
train
themosis/framework
src/Metabox/MetaboxServiceProvider.php
MetaboxServiceProvider.registerMetabox
public function registerMetabox() { $this->app->bind('metabox', function ($app) { $resource = new MetaboxResource( $app->bound('league.fractal') ? $app['league.fractal'] : new Manager(), new ArraySerializer(), new MetaboxTransformer() ); return new Factory($app, $app['action'], $app['filter'], $resource); }); }
php
public function registerMetabox() { $this->app->bind('metabox', function ($app) { $resource = new MetaboxResource( $app->bound('league.fractal') ? $app['league.fractal'] : new Manager(), new ArraySerializer(), new MetaboxTransformer() ); return new Factory($app, $app['action'], $app['filter'], $resource); }); }
[ "public", "function", "registerMetabox", "(", ")", "{", "$", "this", "->", "app", "->", "bind", "(", "'metabox'", ",", "function", "(", "$", "app", ")", "{", "$", "resource", "=", "new", "MetaboxResource", "(", "$", "app", "->", "bound", "(", "'league.fractal'", ")", "?", "$", "app", "[", "'league.fractal'", "]", ":", "new", "Manager", "(", ")", ",", "new", "ArraySerializer", "(", ")", ",", "new", "MetaboxTransformer", "(", ")", ")", ";", "return", "new", "Factory", "(", "$", "app", ",", "$", "app", "[", "'action'", "]", ",", "$", "app", "[", "'filter'", "]", ",", "$", "resource", ")", ";", "}", ")", ";", "}" ]
Register the metabox factory.
[ "Register", "the", "metabox", "factory", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Metabox/MetaboxServiceProvider.php#L29-L40
train
themosis/framework
src/User/UserField.php
UserField.add
public function add($field, SectionInterface $section = null): UserFieldContract { if ($field instanceof SectionInterface) { $section = $field; if ($section->hasItems()) { foreach ($section->getItems() as $item) { /** @var FieldTypeInterface $item */ $item->setOptions([ 'group' => $section->getId() ]); $this->add($item, $section); } } return $this; } // Setup field options $field->setTheme('themosis.users'); $field->setPrefix($this->options['prefix']); $this->repository->addField($field, $this->getSection($field, $section)); return $this; }
php
public function add($field, SectionInterface $section = null): UserFieldContract { if ($field instanceof SectionInterface) { $section = $field; if ($section->hasItems()) { foreach ($section->getItems() as $item) { /** @var FieldTypeInterface $item */ $item->setOptions([ 'group' => $section->getId() ]); $this->add($item, $section); } } return $this; } // Setup field options $field->setTheme('themosis.users'); $field->setPrefix($this->options['prefix']); $this->repository->addField($field, $this->getSection($field, $section)); return $this; }
[ "public", "function", "add", "(", "$", "field", ",", "SectionInterface", "$", "section", "=", "null", ")", ":", "UserFieldContract", "{", "if", "(", "$", "field", "instanceof", "SectionInterface", ")", "{", "$", "section", "=", "$", "field", ";", "if", "(", "$", "section", "->", "hasItems", "(", ")", ")", "{", "foreach", "(", "$", "section", "->", "getItems", "(", ")", "as", "$", "item", ")", "{", "/** @var FieldTypeInterface $item */", "$", "item", "->", "setOptions", "(", "[", "'group'", "=>", "$", "section", "->", "getId", "(", ")", "]", ")", ";", "$", "this", "->", "add", "(", "$", "item", ",", "$", "section", ")", ";", "}", "}", "return", "$", "this", ";", "}", "// Setup field options", "$", "field", "->", "setTheme", "(", "'themosis.users'", ")", ";", "$", "field", "->", "setPrefix", "(", "$", "this", "->", "options", "[", "'prefix'", "]", ")", ";", "$", "this", "->", "repository", "->", "addField", "(", "$", "field", ",", "$", "this", "->", "getSection", "(", "$", "field", ",", "$", "section", ")", ")", ";", "return", "$", "this", ";", "}" ]
Add a user field. @param \Themosis\Forms\Contracts\FieldTypeInterface|SectionInterface $field @param SectionInterface|null $section @return UserFieldContract
[ "Add", "a", "user", "field", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L113-L139
train
themosis/framework
src/User/UserField.php
UserField.getSection
protected function getSection(FieldTypeInterface $field, $section = null): SectionInterface { if (is_null($section)) { if ($this->repository->hasGroup($field->getOption('group'))) { $section = $this->repository->getGroup($field->getOption('group')); } else { $section = new Section($field->getOption('group')); } $section->addItem($field); } return $section; }
php
protected function getSection(FieldTypeInterface $field, $section = null): SectionInterface { if (is_null($section)) { if ($this->repository->hasGroup($field->getOption('group'))) { $section = $this->repository->getGroup($field->getOption('group')); } else { $section = new Section($field->getOption('group')); } $section->addItem($field); } return $section; }
[ "protected", "function", "getSection", "(", "FieldTypeInterface", "$", "field", ",", "$", "section", "=", "null", ")", ":", "SectionInterface", "{", "if", "(", "is_null", "(", "$", "section", ")", ")", "{", "if", "(", "$", "this", "->", "repository", "->", "hasGroup", "(", "$", "field", "->", "getOption", "(", "'group'", ")", ")", ")", "{", "$", "section", "=", "$", "this", "->", "repository", "->", "getGroup", "(", "$", "field", "->", "getOption", "(", "'group'", ")", ")", ";", "}", "else", "{", "$", "section", "=", "new", "Section", "(", "$", "field", "->", "getOption", "(", "'group'", ")", ")", ";", "}", "$", "section", "->", "addItem", "(", "$", "field", ")", ";", "}", "return", "$", "section", ";", "}" ]
Get section for given field. @param FieldTypeInterface $field @param null $section @return SectionInterface
[ "Get", "section", "for", "given", "field", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L149-L162
train
themosis/framework
src/User/UserField.php
UserField.set
public function set(): UserFieldContract { $this->action->add([ 'user_new_form', 'show_user_profile', 'edit_user_profile' ], [$this, 'display']); $this->action->add([ 'user_register', 'profile_update' ], [$this, 'save']); return $this; }
php
public function set(): UserFieldContract { $this->action->add([ 'user_new_form', 'show_user_profile', 'edit_user_profile' ], [$this, 'display']); $this->action->add([ 'user_register', 'profile_update' ], [$this, 'save']); return $this; }
[ "public", "function", "set", "(", ")", ":", "UserFieldContract", "{", "$", "this", "->", "action", "->", "add", "(", "[", "'user_new_form'", ",", "'show_user_profile'", ",", "'edit_user_profile'", "]", ",", "[", "$", "this", ",", "'display'", "]", ")", ";", "$", "this", "->", "action", "->", "add", "(", "[", "'user_register'", ",", "'profile_update'", "]", ",", "[", "$", "this", ",", "'save'", "]", ")", ";", "return", "$", "this", ";", "}" ]
Set the user fields. @return UserFieldContract
[ "Set", "the", "user", "fields", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L169-L183
train
themosis/framework
src/User/UserField.php
UserField.display
public function display($user) { foreach ($this->repository->getGroups() as $group) { /** @var SectionInterface $group */ $fields = $group->getItems(); if (is_a($user, 'WP_User')) { // Initiate the value (edit screens only). array_walk($fields, function ($field) use ($user) { /** @var CanHandleUsers $field */ $field->userGet($user->ID); }); } echo $this->factory->make('themosis.users.main', [ 'section' => $group, 'fields' => $fields ])->render(); } }
php
public function display($user) { foreach ($this->repository->getGroups() as $group) { /** @var SectionInterface $group */ $fields = $group->getItems(); if (is_a($user, 'WP_User')) { // Initiate the value (edit screens only). array_walk($fields, function ($field) use ($user) { /** @var CanHandleUsers $field */ $field->userGet($user->ID); }); } echo $this->factory->make('themosis.users.main', [ 'section' => $group, 'fields' => $fields ])->render(); } }
[ "public", "function", "display", "(", "$", "user", ")", "{", "foreach", "(", "$", "this", "->", "repository", "->", "getGroups", "(", ")", "as", "$", "group", ")", "{", "/** @var SectionInterface $group */", "$", "fields", "=", "$", "group", "->", "getItems", "(", ")", ";", "if", "(", "is_a", "(", "$", "user", ",", "'WP_User'", ")", ")", "{", "// Initiate the value (edit screens only).", "array_walk", "(", "$", "fields", ",", "function", "(", "$", "field", ")", "use", "(", "$", "user", ")", "{", "/** @var CanHandleUsers $field */", "$", "field", "->", "userGet", "(", "$", "user", "->", "ID", ")", ";", "}", ")", ";", "}", "echo", "$", "this", "->", "factory", "->", "make", "(", "'themosis.users.main'", ",", "[", "'section'", "=>", "$", "group", ",", "'fields'", "=>", "$", "fields", "]", ")", "->", "render", "(", ")", ";", "}", "}" ]
Display user meta fields. If adding a user, $user is a string and represent a context: 'add-existing-user' (multisite), 'add-new-user' (single). Else is a WP_User instance. @param mixed $user
[ "Display", "user", "meta", "fields", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L204-L223
train
themosis/framework
src/User/UserField.php
UserField.save
public function save($user_id) { $validator = $this->validator->make( $this->getUserData(app('request')), $this->getUserRules(), $this->getUserMessages(), $this->getUserPlaceholders() ); $validation = $validator->valid(); foreach ($this->repository->all() as $field) { /** @var FieldTypeInterface|BaseType|CanHandleUsers $field */ $field->setErrorMessageBag($validator->errors()); if (method_exists($field, 'userSave')) { $field->userSave($validation[$field->getName()] ?? null, $user_id); } else { throw new UserException('Unable to save ['.$field->getName().']. The [userSave] method is missing.'); } } }
php
public function save($user_id) { $validator = $this->validator->make( $this->getUserData(app('request')), $this->getUserRules(), $this->getUserMessages(), $this->getUserPlaceholders() ); $validation = $validator->valid(); foreach ($this->repository->all() as $field) { /** @var FieldTypeInterface|BaseType|CanHandleUsers $field */ $field->setErrorMessageBag($validator->errors()); if (method_exists($field, 'userSave')) { $field->userSave($validation[$field->getName()] ?? null, $user_id); } else { throw new UserException('Unable to save ['.$field->getName().']. The [userSave] method is missing.'); } } }
[ "public", "function", "save", "(", "$", "user_id", ")", "{", "$", "validator", "=", "$", "this", "->", "validator", "->", "make", "(", "$", "this", "->", "getUserData", "(", "app", "(", "'request'", ")", ")", ",", "$", "this", "->", "getUserRules", "(", ")", ",", "$", "this", "->", "getUserMessages", "(", ")", ",", "$", "this", "->", "getUserPlaceholders", "(", ")", ")", ";", "$", "validation", "=", "$", "validator", "->", "valid", "(", ")", ";", "foreach", "(", "$", "this", "->", "repository", "->", "all", "(", ")", "as", "$", "field", ")", "{", "/** @var FieldTypeInterface|BaseType|CanHandleUsers $field */", "$", "field", "->", "setErrorMessageBag", "(", "$", "validator", "->", "errors", "(", ")", ")", ";", "if", "(", "method_exists", "(", "$", "field", ",", "'userSave'", ")", ")", "{", "$", "field", "->", "userSave", "(", "$", "validation", "[", "$", "field", "->", "getName", "(", ")", "]", "??", "null", ",", "$", "user_id", ")", ";", "}", "else", "{", "throw", "new", "UserException", "(", "'Unable to save ['", ".", "$", "field", "->", "getName", "(", ")", ".", "']. The [userSave] method is missing.'", ")", ";", "}", "}", "}" ]
Save user meta. By default, the callback always contains the user_id as the first parameter. In the case of an update profile, a second parameter is available containing an array of previous user meta data. @param int $user_id @throws UserException
[ "Save", "user", "meta", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L237-L258
train
themosis/framework
src/User/UserField.php
UserField.getUserData
protected function getUserData(Request $request) { $data = []; foreach ($this->repository->all() as $field) { $data[$field->getName()] = $request->get($field->getName()); } return $data; }
php
protected function getUserData(Request $request) { $data = []; foreach ($this->repository->all() as $field) { $data[$field->getName()] = $request->get($field->getName()); } return $data; }
[ "protected", "function", "getUserData", "(", "Request", "$", "request", ")", "{", "$", "data", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "repository", "->", "all", "(", ")", "as", "$", "field", ")", "{", "$", "data", "[", "$", "field", "->", "getName", "(", ")", "]", "=", "$", "request", "->", "get", "(", "$", "field", "->", "getName", "(", ")", ")", ";", "}", "return", "$", "data", ";", "}" ]
Return request user meta data. @param Request $request @return array
[ "Return", "request", "user", "meta", "data", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L267-L276
train
themosis/framework
src/User/UserField.php
UserField.getUserRules
protected function getUserRules() { $rules = []; foreach ($this->repository->all() as $field) { $rules[$field->getName()] = $field->getOption('rules'); } return $rules; }
php
protected function getUserRules() { $rules = []; foreach ($this->repository->all() as $field) { $rules[$field->getName()] = $field->getOption('rules'); } return $rules; }
[ "protected", "function", "getUserRules", "(", ")", "{", "$", "rules", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "repository", "->", "all", "(", ")", "as", "$", "field", ")", "{", "$", "rules", "[", "$", "field", "->", "getName", "(", ")", "]", "=", "$", "field", "->", "getOption", "(", "'rules'", ")", ";", "}", "return", "$", "rules", ";", "}" ]
Return user validation rules. @return array
[ "Return", "user", "validation", "rules", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L283-L292
train
themosis/framework
src/User/UserField.php
UserField.getUserMessages
protected function getUserMessages() { $messages = []; foreach ($this->repository->all() as $field) { foreach ($field->getOption('messages') as $rule => $message) { $messages[$field->getName().'.'.$rule] = $message; } } return $messages; }
php
protected function getUserMessages() { $messages = []; foreach ($this->repository->all() as $field) { foreach ($field->getOption('messages') as $rule => $message) { $messages[$field->getName().'.'.$rule] = $message; } } return $messages; }
[ "protected", "function", "getUserMessages", "(", ")", "{", "$", "messages", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "repository", "->", "all", "(", ")", "as", "$", "field", ")", "{", "foreach", "(", "$", "field", "->", "getOption", "(", "'messages'", ")", "as", "$", "rule", "=>", "$", "message", ")", "{", "$", "messages", "[", "$", "field", "->", "getName", "(", ")", ".", "'.'", ".", "$", "rule", "]", "=", "$", "message", ";", "}", "}", "return", "$", "messages", ";", "}" ]
Return user validation messages. @return array
[ "Return", "user", "validation", "messages", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L299-L310
train
themosis/framework
src/User/UserField.php
UserField.getUserPlaceholders
protected function getUserPlaceholders() { $placeholders = []; foreach ($this->repository->all() as $field) { $placeholders[$field->getName()] = $field->getOption('placeholder'); } return $placeholders; }
php
protected function getUserPlaceholders() { $placeholders = []; foreach ($this->repository->all() as $field) { $placeholders[$field->getName()] = $field->getOption('placeholder'); } return $placeholders; }
[ "protected", "function", "getUserPlaceholders", "(", ")", "{", "$", "placeholders", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "repository", "->", "all", "(", ")", "as", "$", "field", ")", "{", "$", "placeholders", "[", "$", "field", "->", "getName", "(", ")", "]", "=", "$", "field", "->", "getOption", "(", "'placeholder'", ")", ";", "}", "return", "$", "placeholders", ";", "}" ]
Return user validation placeholders. @return array
[ "Return", "user", "validation", "placeholders", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/User/UserField.php#L317-L326
train
themosis/framework
src/Field/Factory.php
Factory.text
public function text(string $name, array $options = []): FieldTypeInterface { return (new TextType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function text(string $name, array $options = []): FieldTypeInterface { return (new TextType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "text", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "TextType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a text type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "text", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L54-L60
train
themosis/framework
src/Field/Factory.php
Factory.password
public function password(string $name, array $options = []): FieldTypeInterface { return (new PasswordType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function password(string $name, array $options = []): FieldTypeInterface { return (new PasswordType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "password", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "PasswordType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a password type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "password", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L70-L76
train
themosis/framework
src/Field/Factory.php
Factory.number
public function number(string $name, array $options = []): FieldTypeInterface { return (new NumberType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function number(string $name, array $options = []): FieldTypeInterface { return (new NumberType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "number", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "NumberType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a number field type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "number", "field", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L86-L92
train
themosis/framework
src/Field/Factory.php
Factory.integer
public function integer(string $name, array $options = []): FieldTypeInterface { return (new IntegerType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function integer(string $name, array $options = []): FieldTypeInterface { return (new IntegerType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "integer", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "IntegerType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return an integer field type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "an", "integer", "field", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L102-L108
train
themosis/framework
src/Field/Factory.php
Factory.email
public function email(string $name, array $options = []): FieldTypeInterface { return (new EmailType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function email(string $name, array $options = []): FieldTypeInterface { return (new EmailType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "email", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "EmailType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return an email type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "an", "email", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L118-L124
train
themosis/framework
src/Field/Factory.php
Factory.date
public function date($name, array $features = [], array $attributes = []) { $properties = [ 'features' => $features, 'atts' => array_merge(['class' => 'newtag'], $attributes, ['data-field' => 'date']), 'name' => $name, ]; return $this->make('Themosis\\Field\\Fields\\DateField', $properties); }
php
public function date($name, array $features = [], array $attributes = []) { $properties = [ 'features' => $features, 'atts' => array_merge(['class' => 'newtag'], $attributes, ['data-field' => 'date']), 'name' => $name, ]; return $this->make('Themosis\\Field\\Fields\\DateField', $properties); }
[ "public", "function", "date", "(", "$", "name", ",", "array", "$", "features", "=", "[", "]", ",", "array", "$", "attributes", "=", "[", "]", ")", "{", "$", "properties", "=", "[", "'features'", "=>", "$", "features", ",", "'atts'", "=>", "array_merge", "(", "[", "'class'", "=>", "'newtag'", "]", ",", "$", "attributes", ",", "[", "'data-field'", "=>", "'date'", "]", ")", ",", "'name'", "=>", "$", "name", ",", "]", ";", "return", "$", "this", "->", "make", "(", "'Themosis\\\\Field\\\\Fields\\\\DateField'", ",", "$", "properties", ")", ";", "}" ]
Return a DateField instance. @param string $name The name attribute of the date input. @param array $features Custom field features - title, info. @param array $attributes Input html attributes. @return \Themosis\Field\Fields\DateField
[ "Return", "a", "DateField", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L135-L144
train
themosis/framework
src/Field/Factory.php
Factory.textarea
public function textarea(string $name, array $options = []): FieldTypeInterface { return (new TextareaType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function textarea(string $name, array $options = []): FieldTypeInterface { return (new TextareaType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "textarea", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "TextareaType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a textarea type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "textarea", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L154-L160
train
themosis/framework
src/Field/Factory.php
Factory.checkbox
public function checkbox(string $name, array $options = []): FieldTypeInterface { return (new CheckboxType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function checkbox(string $name, array $options = []): FieldTypeInterface { return (new CheckboxType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "checkbox", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "CheckboxType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a checkbox type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "checkbox", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L170-L176
train
themosis/framework
src/Field/Factory.php
Factory.choice
public function choice(string $name, array $options = []): FieldTypeInterface { return (new ChoiceType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function choice(string $name, array $options = []): FieldTypeInterface { return (new ChoiceType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "choice", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "ChoiceType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a choice type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "choice", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L186-L192
train
themosis/framework
src/Field/Factory.php
Factory.media
public function media($name, array $options = []): FieldTypeInterface { return (new MediaType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function media($name, array $options = []): FieldTypeInterface { return (new MediaType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "media", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "MediaType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a media type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "media", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L202-L208
train
themosis/framework
src/Field/Factory.php
Factory.editor
public function editor($name, array $options = []): FieldTypeInterface { return (new EditorType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function editor($name, array $options = []): FieldTypeInterface { return (new EditorType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "editor", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "EditorType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return an editor type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "an", "editor", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L218-L224
train
themosis/framework
src/Field/Factory.php
Factory.collection
public function collection($name, array $options = []): FieldTypeInterface { return (new CollectionType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function collection($name, array $options = []): FieldTypeInterface { return (new CollectionType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "collection", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "CollectionType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a collection type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "collection", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L234-L240
train
themosis/framework
src/Field/Factory.php
Factory.color
public function color($name, array $options = []): FieldTypeInterface { return (new ColorType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function color($name, array $options = []): FieldTypeInterface { return (new ColorType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "color", "(", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "ColorType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a color type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "color", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L250-L256
train
themosis/framework
src/Field/Factory.php
Factory.button
public function button(string $name, array $options = []): FieldTypeInterface { return (new ButtonType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function button(string $name, array $options = []): FieldTypeInterface { return (new ButtonType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "button", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "ButtonType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a button type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "button", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L266-L272
train
themosis/framework
src/Field/Factory.php
Factory.submit
public function submit(string $name, array $options = []): FieldTypeInterface { return (new SubmitType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function submit(string $name, array $options = []): FieldTypeInterface { return (new SubmitType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "submit", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "SubmitType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a submit type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "submit", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L282-L288
train
themosis/framework
src/Field/Factory.php
Factory.hidden
public function hidden(string $name, array $options = []): FieldTypeInterface { return (new HiddenType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
php
public function hidden(string $name, array $options = []): FieldTypeInterface { return (new HiddenType($name)) ->setLocale($this->app->getLocale()) ->setViewFactory($this->viewFactory) ->setOptions($options); }
[ "public", "function", "hidden", "(", "string", "$", "name", ",", "array", "$", "options", "=", "[", "]", ")", ":", "FieldTypeInterface", "{", "return", "(", "new", "HiddenType", "(", "$", "name", ")", ")", "->", "setLocale", "(", "$", "this", "->", "app", "->", "getLocale", "(", ")", ")", "->", "setViewFactory", "(", "$", "this", "->", "viewFactory", ")", "->", "setOptions", "(", "$", "options", ")", ";", "}" ]
Return a hidden type instance. @param string $name @param array $options @return FieldTypeInterface
[ "Return", "a", "hidden", "type", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Field/Factory.php#L298-L304
train
themosis/framework
src/Forms/Fields/Types/IntegerType.php
IntegerType.metaboxSave
public function metaboxSave($value, int $post_id) { $this->setValue($value); $previous = get_post_meta($post_id, $this->getName(), true); if (is_null($this->getValue()) || empty($this->getValue())) { delete_post_meta($post_id, $this->getName()); } elseif (empty($previous)) { add_post_meta($post_id, $this->getName(), $this->getRawValue(), true); } else { update_post_meta($post_id, $this->getName(), $this->getRawValue(), $previous); } }
php
public function metaboxSave($value, int $post_id) { $this->setValue($value); $previous = get_post_meta($post_id, $this->getName(), true); if (is_null($this->getValue()) || empty($this->getValue())) { delete_post_meta($post_id, $this->getName()); } elseif (empty($previous)) { add_post_meta($post_id, $this->getName(), $this->getRawValue(), true); } else { update_post_meta($post_id, $this->getName(), $this->getRawValue(), $previous); } }
[ "public", "function", "metaboxSave", "(", "$", "value", ",", "int", "$", "post_id", ")", "{", "$", "this", "->", "setValue", "(", "$", "value", ")", ";", "$", "previous", "=", "get_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ",", "true", ")", ";", "if", "(", "is_null", "(", "$", "this", "->", "getValue", "(", ")", ")", "||", "empty", "(", "$", "this", "->", "getValue", "(", ")", ")", ")", "{", "delete_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ")", ";", "}", "elseif", "(", "empty", "(", "$", "previous", ")", ")", "{", "add_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "this", "->", "getRawValue", "(", ")", ",", "true", ")", ";", "}", "else", "{", "update_post_meta", "(", "$", "post_id", ",", "$", "this", "->", "getName", "(", ")", ",", "$", "this", "->", "getRawValue", "(", ")", ",", "$", "previous", ")", ";", "}", "}" ]
Handle integer field post meta registration. @param string $value @param int $post_id
[ "Handle", "integer", "field", "post", "meta", "registration", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/IntegerType.php#L58-L71
train
themosis/framework
src/Taxonomy/Factory.php
Factory.make
public function make(string $slug, $objects, string $plural, string $singular): TaxonomyInterface { $taxonomy = (new Taxonomy($slug, (array) $objects, $this->container, $this->action)) ->setLabels([ 'name' => $plural, 'singular_name' => $singular, 'search_items' => sprintf('Search %s', $plural), 'popular_items' => sprintf('Popular %s', $plural), 'all_items' => sprintf('All %s', $plural), 'parent_item' => sprintf('Parent %s', $singular), 'parent_item_colon' => sprintf('Parent %s:', $singular), 'edit_item' => sprintf('Edit %s', $singular), 'view_item' => sprintf('View %s', $singular), 'update_item' => sprintf('Update %s', $singular), 'add_new_item' => sprintf('Add New %s', $singular), 'new_item_name' => sprintf('New %s Name', $singular), 'separate_items_with_commas' => sprintf('Separate %s with commas', strtolower($plural)), 'add_or_remove_items' => sprintf('Add or remove %s', strtolower($plural)), 'choose_from_most_used' => sprintf('Choose from the most used %s', strtolower($plural)), 'not_found' => sprintf('No %s found', strtolower($plural)), 'no_terms' => sprintf('No %s', strtolower($plural)), 'items_list_navigation' => sprintf('%s list navigation', $plural), 'items_list' => sprintf('%s list', $plural), 'most_used' => 'Most Used', 'back_to_items' => sprintf('Back to %s', $plural) ]) ->setArguments([ 'public' => true, 'show_in_rest' => true, 'show_admin_column' => true ]); $abstract = sprintf('themosis.taxonomy.%s', $slug); if (! $this->container->bound($abstract)) { $this->container->instance($abstract, $taxonomy); } else { throw new TaxonomyException('The taxonomy ['.$slug.'] already exists.'); } return $taxonomy; }
php
public function make(string $slug, $objects, string $plural, string $singular): TaxonomyInterface { $taxonomy = (new Taxonomy($slug, (array) $objects, $this->container, $this->action)) ->setLabels([ 'name' => $plural, 'singular_name' => $singular, 'search_items' => sprintf('Search %s', $plural), 'popular_items' => sprintf('Popular %s', $plural), 'all_items' => sprintf('All %s', $plural), 'parent_item' => sprintf('Parent %s', $singular), 'parent_item_colon' => sprintf('Parent %s:', $singular), 'edit_item' => sprintf('Edit %s', $singular), 'view_item' => sprintf('View %s', $singular), 'update_item' => sprintf('Update %s', $singular), 'add_new_item' => sprintf('Add New %s', $singular), 'new_item_name' => sprintf('New %s Name', $singular), 'separate_items_with_commas' => sprintf('Separate %s with commas', strtolower($plural)), 'add_or_remove_items' => sprintf('Add or remove %s', strtolower($plural)), 'choose_from_most_used' => sprintf('Choose from the most used %s', strtolower($plural)), 'not_found' => sprintf('No %s found', strtolower($plural)), 'no_terms' => sprintf('No %s', strtolower($plural)), 'items_list_navigation' => sprintf('%s list navigation', $plural), 'items_list' => sprintf('%s list', $plural), 'most_used' => 'Most Used', 'back_to_items' => sprintf('Back to %s', $plural) ]) ->setArguments([ 'public' => true, 'show_in_rest' => true, 'show_admin_column' => true ]); $abstract = sprintf('themosis.taxonomy.%s', $slug); if (! $this->container->bound($abstract)) { $this->container->instance($abstract, $taxonomy); } else { throw new TaxonomyException('The taxonomy ['.$slug.'] already exists.'); } return $taxonomy; }
[ "public", "function", "make", "(", "string", "$", "slug", ",", "$", "objects", ",", "string", "$", "plural", ",", "string", "$", "singular", ")", ":", "TaxonomyInterface", "{", "$", "taxonomy", "=", "(", "new", "Taxonomy", "(", "$", "slug", ",", "(", "array", ")", "$", "objects", ",", "$", "this", "->", "container", ",", "$", "this", "->", "action", ")", ")", "->", "setLabels", "(", "[", "'name'", "=>", "$", "plural", ",", "'singular_name'", "=>", "$", "singular", ",", "'search_items'", "=>", "sprintf", "(", "'Search %s'", ",", "$", "plural", ")", ",", "'popular_items'", "=>", "sprintf", "(", "'Popular %s'", ",", "$", "plural", ")", ",", "'all_items'", "=>", "sprintf", "(", "'All %s'", ",", "$", "plural", ")", ",", "'parent_item'", "=>", "sprintf", "(", "'Parent %s'", ",", "$", "singular", ")", ",", "'parent_item_colon'", "=>", "sprintf", "(", "'Parent %s:'", ",", "$", "singular", ")", ",", "'edit_item'", "=>", "sprintf", "(", "'Edit %s'", ",", "$", "singular", ")", ",", "'view_item'", "=>", "sprintf", "(", "'View %s'", ",", "$", "singular", ")", ",", "'update_item'", "=>", "sprintf", "(", "'Update %s'", ",", "$", "singular", ")", ",", "'add_new_item'", "=>", "sprintf", "(", "'Add New %s'", ",", "$", "singular", ")", ",", "'new_item_name'", "=>", "sprintf", "(", "'New %s Name'", ",", "$", "singular", ")", ",", "'separate_items_with_commas'", "=>", "sprintf", "(", "'Separate %s with commas'", ",", "strtolower", "(", "$", "plural", ")", ")", ",", "'add_or_remove_items'", "=>", "sprintf", "(", "'Add or remove %s'", ",", "strtolower", "(", "$", "plural", ")", ")", ",", "'choose_from_most_used'", "=>", "sprintf", "(", "'Choose from the most used %s'", ",", "strtolower", "(", "$", "plural", ")", ")", ",", "'not_found'", "=>", "sprintf", "(", "'No %s found'", ",", "strtolower", "(", "$", "plural", ")", ")", ",", "'no_terms'", "=>", "sprintf", "(", "'No %s'", ",", "strtolower", "(", "$", "plural", ")", ")", ",", "'items_list_navigation'", "=>", "sprintf", "(", "'%s list navigation'", ",", "$", "plural", ")", ",", "'items_list'", "=>", "sprintf", "(", "'%s list'", ",", "$", "plural", ")", ",", "'most_used'", "=>", "'Most Used'", ",", "'back_to_items'", "=>", "sprintf", "(", "'Back to %s'", ",", "$", "plural", ")", "]", ")", "->", "setArguments", "(", "[", "'public'", "=>", "true", ",", "'show_in_rest'", "=>", "true", ",", "'show_admin_column'", "=>", "true", "]", ")", ";", "$", "abstract", "=", "sprintf", "(", "'themosis.taxonomy.%s'", ",", "$", "slug", ")", ";", "if", "(", "!", "$", "this", "->", "container", "->", "bound", "(", "$", "abstract", ")", ")", "{", "$", "this", "->", "container", "->", "instance", "(", "$", "abstract", ",", "$", "taxonomy", ")", ";", "}", "else", "{", "throw", "new", "TaxonomyException", "(", "'The taxonomy ['", ".", "$", "slug", ".", "'] already exists.'", ")", ";", "}", "return", "$", "taxonomy", ";", "}" ]
Register a taxonomy. @param string $slug @param string|array $objects @param string $plural @param string $singular @throws TaxonomyException @return TaxonomyInterface
[ "Register", "a", "taxonomy", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Taxonomy/Factory.php#L39-L80
train
themosis/framework
src/Auth/Console/AuthMakeCommand.php
AuthMakeCommand.createDirectories
protected function createDirectories() { if (! $this->files->isDirectory($directory = app_path('Forms/Auth/Passwords'))) { $this->files->makeDirectory($directory, 0755, true); } if (! $this->files->isDirectory($directory = app_path('Http/Controllers/Auth'))) { $this->files->makeDirectory($directory, 0755, true); } if (! $this->files->isDirectory($directory = resource_path('views/auth/passwords'))) { $this->files->makeDirectory($directory, 0755, true); } if (! $this->files->isDirectory($directory = resource_path('views/settings'))) { $this->files->makeDirectory($directory, 0755, true); } }
php
protected function createDirectories() { if (! $this->files->isDirectory($directory = app_path('Forms/Auth/Passwords'))) { $this->files->makeDirectory($directory, 0755, true); } if (! $this->files->isDirectory($directory = app_path('Http/Controllers/Auth'))) { $this->files->makeDirectory($directory, 0755, true); } if (! $this->files->isDirectory($directory = resource_path('views/auth/passwords'))) { $this->files->makeDirectory($directory, 0755, true); } if (! $this->files->isDirectory($directory = resource_path('views/settings'))) { $this->files->makeDirectory($directory, 0755, true); } }
[ "protected", "function", "createDirectories", "(", ")", "{", "if", "(", "!", "$", "this", "->", "files", "->", "isDirectory", "(", "$", "directory", "=", "app_path", "(", "'Forms/Auth/Passwords'", ")", ")", ")", "{", "$", "this", "->", "files", "->", "makeDirectory", "(", "$", "directory", ",", "0755", ",", "true", ")", ";", "}", "if", "(", "!", "$", "this", "->", "files", "->", "isDirectory", "(", "$", "directory", "=", "app_path", "(", "'Http/Controllers/Auth'", ")", ")", ")", "{", "$", "this", "->", "files", "->", "makeDirectory", "(", "$", "directory", ",", "0755", ",", "true", ")", ";", "}", "if", "(", "!", "$", "this", "->", "files", "->", "isDirectory", "(", "$", "directory", "=", "resource_path", "(", "'views/auth/passwords'", ")", ")", ")", "{", "$", "this", "->", "files", "->", "makeDirectory", "(", "$", "directory", ",", "0755", ",", "true", ")", ";", "}", "if", "(", "!", "$", "this", "->", "files", "->", "isDirectory", "(", "$", "directory", "=", "resource_path", "(", "'views/settings'", ")", ")", ")", "{", "$", "this", "->", "files", "->", "makeDirectory", "(", "$", "directory", ",", "0755", ",", "true", ")", ";", "}", "}" ]
Create auth necessary directories.
[ "Create", "auth", "necessary", "directories", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Auth/Console/AuthMakeCommand.php#L106-L123
train
themosis/framework
src/Auth/Console/AuthMakeCommand.php
AuthMakeCommand.exportViews
protected function exportViews() { foreach ($this->views as $pathIn => $pathOut) { if ($this->files->exists($view = resource_path('views/'.$pathOut)) && ! $this->option('force')) { if (! $this->confirm("The [{$pathOut}] view already exists. Do you want to overwrite it?")) { continue; } } $this->files->copy( __DIR__.'/stubs/make/views/'.$pathIn, $view ); } }
php
protected function exportViews() { foreach ($this->views as $pathIn => $pathOut) { if ($this->files->exists($view = resource_path('views/'.$pathOut)) && ! $this->option('force')) { if (! $this->confirm("The [{$pathOut}] view already exists. Do you want to overwrite it?")) { continue; } } $this->files->copy( __DIR__.'/stubs/make/views/'.$pathIn, $view ); } }
[ "protected", "function", "exportViews", "(", ")", "{", "foreach", "(", "$", "this", "->", "views", "as", "$", "pathIn", "=>", "$", "pathOut", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "view", "=", "resource_path", "(", "'views/'", ".", "$", "pathOut", ")", ")", "&&", "!", "$", "this", "->", "option", "(", "'force'", ")", ")", "{", "if", "(", "!", "$", "this", "->", "confirm", "(", "\"The [{$pathOut}] view already exists. Do you want to overwrite it?\"", ")", ")", "{", "continue", ";", "}", "}", "$", "this", "->", "files", "->", "copy", "(", "__DIR__", ".", "'/stubs/make/views/'", ".", "$", "pathIn", ",", "$", "view", ")", ";", "}", "}" ]
Export authentication default views.
[ "Export", "authentication", "default", "views", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Auth/Console/AuthMakeCommand.php#L128-L142
train
themosis/framework
src/Auth/Console/AuthMakeCommand.php
AuthMakeCommand.exportControllers
protected function exportControllers() { foreach ($this->controllers as $pathIn => $pathOut) { if ($this->files->exists($controller = app_path('Http/Controllers/'.$pathOut)) && ! $this->option('force')) { if (! $this->confirm("The [{$pathOut}] controller already exists. Do you want to overwrite it?")) { continue; } } $this->files->put( $controller, $this->compileStub($this->files->get(__DIR__.'/stubs/make/controllers/'.$pathIn)) ); } }
php
protected function exportControllers() { foreach ($this->controllers as $pathIn => $pathOut) { if ($this->files->exists($controller = app_path('Http/Controllers/'.$pathOut)) && ! $this->option('force')) { if (! $this->confirm("The [{$pathOut}] controller already exists. Do you want to overwrite it?")) { continue; } } $this->files->put( $controller, $this->compileStub($this->files->get(__DIR__.'/stubs/make/controllers/'.$pathIn)) ); } }
[ "protected", "function", "exportControllers", "(", ")", "{", "foreach", "(", "$", "this", "->", "controllers", "as", "$", "pathIn", "=>", "$", "pathOut", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "controller", "=", "app_path", "(", "'Http/Controllers/'", ".", "$", "pathOut", ")", ")", "&&", "!", "$", "this", "->", "option", "(", "'force'", ")", ")", "{", "if", "(", "!", "$", "this", "->", "confirm", "(", "\"The [{$pathOut}] controller already exists. Do you want to overwrite it?\"", ")", ")", "{", "continue", ";", "}", "}", "$", "this", "->", "files", "->", "put", "(", "$", "controller", ",", "$", "this", "->", "compileStub", "(", "$", "this", "->", "files", "->", "get", "(", "__DIR__", ".", "'/stubs/make/controllers/'", ".", "$", "pathIn", ")", ")", ")", ";", "}", "}" ]
Export authentication default controllers.
[ "Export", "authentication", "default", "controllers", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Auth/Console/AuthMakeCommand.php#L147-L162
train
themosis/framework
src/Auth/Console/AuthMakeCommand.php
AuthMakeCommand.exportForms
protected function exportForms() { foreach ($this->forms as $pathIn => $pathOut) { if ($this->files->exists($form = app_path('Forms/'.$pathOut)) && ! $this->option('force')) { if (! $this->confirm("The [{$pathOut}] form already exists. Do you want to overwrite it?")) { continue; } } $this->files->put( $form, $this->compileStub($this->files->get(__DIR__.'/stubs/make/forms/'.$pathIn)) ); } }
php
protected function exportForms() { foreach ($this->forms as $pathIn => $pathOut) { if ($this->files->exists($form = app_path('Forms/'.$pathOut)) && ! $this->option('force')) { if (! $this->confirm("The [{$pathOut}] form already exists. Do you want to overwrite it?")) { continue; } } $this->files->put( $form, $this->compileStub($this->files->get(__DIR__.'/stubs/make/forms/'.$pathIn)) ); } }
[ "protected", "function", "exportForms", "(", ")", "{", "foreach", "(", "$", "this", "->", "forms", "as", "$", "pathIn", "=>", "$", "pathOut", ")", "{", "if", "(", "$", "this", "->", "files", "->", "exists", "(", "$", "form", "=", "app_path", "(", "'Forms/'", ".", "$", "pathOut", ")", ")", "&&", "!", "$", "this", "->", "option", "(", "'force'", ")", ")", "{", "if", "(", "!", "$", "this", "->", "confirm", "(", "\"The [{$pathOut}] form already exists. Do you want to overwrite it?\"", ")", ")", "{", "continue", ";", "}", "}", "$", "this", "->", "files", "->", "put", "(", "$", "form", ",", "$", "this", "->", "compileStub", "(", "$", "this", "->", "files", "->", "get", "(", "__DIR__", ".", "'/stubs/make/forms/'", ".", "$", "pathIn", ")", ")", ")", ";", "}", "}" ]
Export authentication default forms.
[ "Export", "authentication", "default", "forms", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Auth/Console/AuthMakeCommand.php#L167-L181
train
themosis/framework
src/Route/AdminRoute.php
AdminRoute.get
public function get() { $wordpressUri = trim(config('app.wp.dir', 'cms'), '\/'); $route = $this->router->any($wordpressUri.'/wp-admin/{any?}', function () { return new Response(); }); $route->middleware('admin'); $route->bind($this->request); return $route; }
php
public function get() { $wordpressUri = trim(config('app.wp.dir', 'cms'), '\/'); $route = $this->router->any($wordpressUri.'/wp-admin/{any?}', function () { return new Response(); }); $route->middleware('admin'); $route->bind($this->request); return $route; }
[ "public", "function", "get", "(", ")", "{", "$", "wordpressUri", "=", "trim", "(", "config", "(", "'app.wp.dir'", ",", "'cms'", ")", ",", "'\\/'", ")", ";", "$", "route", "=", "$", "this", "->", "router", "->", "any", "(", "$", "wordpressUri", ".", "'/wp-admin/{any?}'", ",", "function", "(", ")", "{", "return", "new", "Response", "(", ")", ";", "}", ")", ";", "$", "route", "->", "middleware", "(", "'admin'", ")", ";", "$", "route", "->", "bind", "(", "$", "this", "->", "request", ")", ";", "return", "$", "route", ";", "}" ]
Return the catch-all WordPress administration route. @throws \Illuminate\Container\EntryNotFoundException @return \Illuminate\Routing\Route
[ "Return", "the", "catch", "-", "all", "WordPress", "administration", "route", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Route/AdminRoute.php#L34-L45
train
themosis/framework
src/Core/PluginManager.php
PluginManager.setDirectory
public function setDirectory() { $pos = strrpos($this->dirPath, DIRECTORY_SEPARATOR); $this->directory = substr($this->dirPath, $pos + 1); }
php
public function setDirectory() { $pos = strrpos($this->dirPath, DIRECTORY_SEPARATOR); $this->directory = substr($this->dirPath, $pos + 1); }
[ "public", "function", "setDirectory", "(", ")", "{", "$", "pos", "=", "strrpos", "(", "$", "this", "->", "dirPath", ",", "DIRECTORY_SEPARATOR", ")", ";", "$", "this", "->", "directory", "=", "substr", "(", "$", "this", "->", "dirPath", ",", "$", "pos", "+", "1", ")", ";", "}" ]
Set the plugin directory name.
[ "Set", "the", "plugin", "directory", "name", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginManager.php#L88-L92
train
themosis/framework
src/Core/PluginManager.php
PluginManager.getPath
public function getPath(string $path = ''): string { return $this->dirPath.($path ? DIRECTORY_SEPARATOR.$path : $path); }
php
public function getPath(string $path = ''): string { return $this->dirPath.($path ? DIRECTORY_SEPARATOR.$path : $path); }
[ "public", "function", "getPath", "(", "string", "$", "path", "=", "''", ")", ":", "string", "{", "return", "$", "this", "->", "dirPath", ".", "(", "$", "path", "?", "DIRECTORY_SEPARATOR", ".", "$", "path", ":", "$", "path", ")", ";", "}" ]
Return the plugin root path. @param string $path Path to append to the plugin root path. @return string
[ "Return", "the", "plugin", "root", "path", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginManager.php#L111-L114
train
themosis/framework
src/Core/PluginManager.php
PluginManager.config
public function config(string $key, $default = null) { $fullnameKey = $this->getNamespace().'_'.$key; return $this->config->get($fullnameKey, $default); }
php
public function config(string $key, $default = null) { $fullnameKey = $this->getNamespace().'_'.$key; return $this->config->get($fullnameKey, $default); }
[ "public", "function", "config", "(", "string", "$", "key", ",", "$", "default", "=", "null", ")", "{", "$", "fullnameKey", "=", "$", "this", "->", "getNamespace", "(", ")", ".", "'_'", ".", "$", "key", ";", "return", "$", "this", "->", "config", "->", "get", "(", "$", "fullnameKey", ",", "$", "default", ")", ";", "}" ]
Return a plugin configuration value. @param string $key Key configuration short name. @param mixed $default @return mixed
[ "Return", "a", "plugin", "configuration", "value", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginManager.php#L158-L163
train
themosis/framework
src/Core/PluginManager.php
PluginManager.setConstants
protected function setConstants() { $this->parsedHeaders = $this->headers($this->filePath, $this->headers); $domainVar = $this->parsedHeaders['domain_var'] ?? 'PLUGIN_TD'; $domainVar = strtoupper($domainVar); $textDomain = $this->parsedHeaders['text_domain'] ?? 'plugin-textdomain'; if (! defined($domainVar)) { define($domainVar, $textDomain); } }
php
protected function setConstants() { $this->parsedHeaders = $this->headers($this->filePath, $this->headers); $domainVar = $this->parsedHeaders['domain_var'] ?? 'PLUGIN_TD'; $domainVar = strtoupper($domainVar); $textDomain = $this->parsedHeaders['text_domain'] ?? 'plugin-textdomain'; if (! defined($domainVar)) { define($domainVar, $textDomain); } }
[ "protected", "function", "setConstants", "(", ")", "{", "$", "this", "->", "parsedHeaders", "=", "$", "this", "->", "headers", "(", "$", "this", "->", "filePath", ",", "$", "this", "->", "headers", ")", ";", "$", "domainVar", "=", "$", "this", "->", "parsedHeaders", "[", "'domain_var'", "]", "??", "'PLUGIN_TD'", ";", "$", "domainVar", "=", "strtoupper", "(", "$", "domainVar", ")", ";", "$", "textDomain", "=", "$", "this", "->", "parsedHeaders", "[", "'text_domain'", "]", "??", "'plugin-textdomain'", ";", "if", "(", "!", "defined", "(", "$", "domainVar", ")", ")", "{", "define", "(", "$", "domainVar", ",", "$", "textDomain", ")", ";", "}", "}" ]
Set plugin headers and plugin text domain constant.
[ "Set", "plugin", "headers", "and", "plugin", "text", "domain", "constant", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginManager.php#L187-L198
train
themosis/framework
src/Core/PluginManager.php
PluginManager.loadPluginConfiguration
protected function loadPluginConfiguration(string $configPath) { $this->app->loadConfigurationFiles($this->config, $this->dirPath.'/'.trim($configPath, '\/')); }
php
protected function loadPluginConfiguration(string $configPath) { $this->app->loadConfigurationFiles($this->config, $this->dirPath.'/'.trim($configPath, '\/')); }
[ "protected", "function", "loadPluginConfiguration", "(", "string", "$", "configPath", ")", "{", "$", "this", "->", "app", "->", "loadConfigurationFiles", "(", "$", "this", "->", "config", ",", "$", "this", "->", "dirPath", ".", "'/'", ".", "trim", "(", "$", "configPath", ",", "'\\/'", ")", ")", ";", "}" ]
Load plugin configuration files. @param string $configPath
[ "Load", "plugin", "configuration", "files", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginManager.php#L215-L218
train
themosis/framework
src/Core/PluginManager.php
PluginManager.setPluginAutoloading
protected function setPluginAutoloading() { foreach ($this->config('plugin.autoloading', []) as $ns => $path) { $path = $this->dirPath.'/'.trim($path, '\/'); $this->loader->addPsr4($ns, $path); } $this->loader->register(); }
php
protected function setPluginAutoloading() { foreach ($this->config('plugin.autoloading', []) as $ns => $path) { $path = $this->dirPath.'/'.trim($path, '\/'); $this->loader->addPsr4($ns, $path); } $this->loader->register(); }
[ "protected", "function", "setPluginAutoloading", "(", ")", "{", "foreach", "(", "$", "this", "->", "config", "(", "'plugin.autoloading'", ",", "[", "]", ")", "as", "$", "ns", "=>", "$", "path", ")", "{", "$", "path", "=", "$", "this", "->", "dirPath", ".", "'/'", ".", "trim", "(", "$", "path", ",", "'\\/'", ")", ";", "$", "this", "->", "loader", "->", "addPsr4", "(", "$", "ns", ",", "$", "path", ")", ";", "}", "$", "this", "->", "loader", "->", "register", "(", ")", ";", "}" ]
Load plugin classes.
[ "Load", "plugin", "classes", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/PluginManager.php#L223-L231
train
themosis/framework
src/Hook/FilterBuilder.php
FilterBuilder.run
public function run($hook, $args = null) { if (is_array($args)) { return $this->applyFiltersRefArray($hook, $args); } return $this->applyFilters($hook, $args); }
php
public function run($hook, $args = null) { if (is_array($args)) { return $this->applyFiltersRefArray($hook, $args); } return $this->applyFilters($hook, $args); }
[ "public", "function", "run", "(", "$", "hook", ",", "$", "args", "=", "null", ")", "{", "if", "(", "is_array", "(", "$", "args", ")", ")", "{", "return", "$", "this", "->", "applyFiltersRefArray", "(", "$", "hook", ",", "$", "args", ")", ";", "}", "return", "$", "this", "->", "applyFilters", "(", "$", "hook", ",", "$", "args", ")", ";", "}" ]
Run all filters registered with the hook. @param string $hook The filter hook name. @param mixed $args @return mixed
[ "Run", "all", "filters", "registered", "with", "the", "hook", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Hook/FilterBuilder.php#L15-L22
train
themosis/framework
src/Hook/FilterBuilder.php
FilterBuilder.addEventListener
protected function addEventListener($name, $callback, $priority, $accepted_args) { $this->hooks[$name] = [$callback, $priority, $accepted_args]; $this->addFilter($name, $callback, $priority, $accepted_args); }
php
protected function addEventListener($name, $callback, $priority, $accepted_args) { $this->hooks[$name] = [$callback, $priority, $accepted_args]; $this->addFilter($name, $callback, $priority, $accepted_args); }
[ "protected", "function", "addEventListener", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", "{", "$", "this", "->", "hooks", "[", "$", "name", "]", "=", "[", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", "]", ";", "$", "this", "->", "addFilter", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", ";", "}" ]
Add a filter event for the specified hook. @param string $name @param \Closure|string|array $callback @param int $priority @param int $accepted_args
[ "Add", "a", "filter", "event", "for", "the", "specified", "hook", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Hook/FilterBuilder.php#L58-L62
train
themosis/framework
src/Hook/FilterBuilder.php
FilterBuilder.addFilter
protected function addFilter($name, $callback, $priority, $accepted_args) { add_filter($name, $callback, $priority, $accepted_args); }
php
protected function addFilter($name, $callback, $priority, $accepted_args) { add_filter($name, $callback, $priority, $accepted_args); }
[ "protected", "function", "addFilter", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", "{", "add_filter", "(", "$", "name", ",", "$", "callback", ",", "$", "priority", ",", "$", "accepted_args", ")", ";", "}" ]
Calls the WordPress add_filter function in order to listen to a filter hook. @param string $name @param \Closure|string|array $callback @param int $priority @param int $accepted_args
[ "Calls", "the", "WordPress", "add_filter", "function", "in", "order", "to", "listen", "to", "a", "filter", "hook", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Hook/FilterBuilder.php#L72-L75
train
themosis/framework
src/Core/Theme/Templates.php
Templates.parse
protected function parse(array $options) { $templates = [ 'page' => [] ]; foreach ($options as $slug => $properties) { // 1 - $slug is int -> meaning it's only for pages // and $properties is the slug name. if (is_int($slug)) { $templates['page'][$properties] = $this->formatName($properties); } else { // 2 - (associative array) $slug is a string and we're dealing with $properties. // 2.1 - $properties is a string only, so the template is only available to page. if (is_string($properties)) { $templates['page'][$slug] = $properties; } // 2.2 - $properties is an array. if (is_array($properties) && ! empty($properties)) { // 2.2.1 - $properties has only one value, meaning it's a display name //and only available to page. if (1 === count($properties) && is_string($properties[0])) { $templates['page'][$slug] = $properties[0]; } // 2.2.2 - $properties has 2 values if (2 === count($properties)) { // 2.2.2.1 - Loop through the second one (cast it as array in case of). $post_types = (array) $properties[1]; foreach ($post_types as $post_type) { $post_type = trim($post_type); // Verify if $post_type exists. If not, add it with a default value. if (! isset($templates[$post_type])) { $templates[$post_type] = []; } // The is a $post_type in the $templates. // Basically, add the templates to each one of them. $templates[$post_type][$slug] = is_string($properties[0]) ? trim($properties[0]) : $this->formatName($slug); } } } } } return $templates; }
php
protected function parse(array $options) { $templates = [ 'page' => [] ]; foreach ($options as $slug => $properties) { // 1 - $slug is int -> meaning it's only for pages // and $properties is the slug name. if (is_int($slug)) { $templates['page'][$properties] = $this->formatName($properties); } else { // 2 - (associative array) $slug is a string and we're dealing with $properties. // 2.1 - $properties is a string only, so the template is only available to page. if (is_string($properties)) { $templates['page'][$slug] = $properties; } // 2.2 - $properties is an array. if (is_array($properties) && ! empty($properties)) { // 2.2.1 - $properties has only one value, meaning it's a display name //and only available to page. if (1 === count($properties) && is_string($properties[0])) { $templates['page'][$slug] = $properties[0]; } // 2.2.2 - $properties has 2 values if (2 === count($properties)) { // 2.2.2.1 - Loop through the second one (cast it as array in case of). $post_types = (array) $properties[1]; foreach ($post_types as $post_type) { $post_type = trim($post_type); // Verify if $post_type exists. If not, add it with a default value. if (! isset($templates[$post_type])) { $templates[$post_type] = []; } // The is a $post_type in the $templates. // Basically, add the templates to each one of them. $templates[$post_type][$slug] = is_string($properties[0]) ? trim($properties[0]) : $this->formatName($slug); } } } } } return $templates; }
[ "protected", "function", "parse", "(", "array", "$", "options", ")", "{", "$", "templates", "=", "[", "'page'", "=>", "[", "]", "]", ";", "foreach", "(", "$", "options", "as", "$", "slug", "=>", "$", "properties", ")", "{", "// 1 - $slug is int -> meaning it's only for pages", "// and $properties is the slug name.", "if", "(", "is_int", "(", "$", "slug", ")", ")", "{", "$", "templates", "[", "'page'", "]", "[", "$", "properties", "]", "=", "$", "this", "->", "formatName", "(", "$", "properties", ")", ";", "}", "else", "{", "// 2 - (associative array) $slug is a string and we're dealing with $properties.", "// 2.1 - $properties is a string only, so the template is only available to page.", "if", "(", "is_string", "(", "$", "properties", ")", ")", "{", "$", "templates", "[", "'page'", "]", "[", "$", "slug", "]", "=", "$", "properties", ";", "}", "// 2.2 - $properties is an array.", "if", "(", "is_array", "(", "$", "properties", ")", "&&", "!", "empty", "(", "$", "properties", ")", ")", "{", "// 2.2.1 - $properties has only one value, meaning it's a display name", "//and only available to page.", "if", "(", "1", "===", "count", "(", "$", "properties", ")", "&&", "is_string", "(", "$", "properties", "[", "0", "]", ")", ")", "{", "$", "templates", "[", "'page'", "]", "[", "$", "slug", "]", "=", "$", "properties", "[", "0", "]", ";", "}", "// 2.2.2 - $properties has 2 values", "if", "(", "2", "===", "count", "(", "$", "properties", ")", ")", "{", "// 2.2.2.1 - Loop through the second one (cast it as array in case of).", "$", "post_types", "=", "(", "array", ")", "$", "properties", "[", "1", "]", ";", "foreach", "(", "$", "post_types", "as", "$", "post_type", ")", "{", "$", "post_type", "=", "trim", "(", "$", "post_type", ")", ";", "// Verify if $post_type exists. If not, add it with a default value.", "if", "(", "!", "isset", "(", "$", "templates", "[", "$", "post_type", "]", ")", ")", "{", "$", "templates", "[", "$", "post_type", "]", "=", "[", "]", ";", "}", "// The is a $post_type in the $templates.", "// Basically, add the templates to each one of them.", "$", "templates", "[", "$", "post_type", "]", "[", "$", "slug", "]", "=", "is_string", "(", "$", "properties", "[", "0", "]", ")", "?", "trim", "(", "$", "properties", "[", "0", "]", ")", ":", "$", "this", "->", "formatName", "(", "$", "slug", ")", ";", "}", "}", "}", "}", "}", "return", "$", "templates", ";", "}" ]
Parse templates. @param array $options @return array
[ "Parse", "templates", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Theme/Templates.php#L32-L83
train
themosis/framework
src/Core/Theme/Templates.php
Templates.register
public function register() { foreach ($this->templates as $post_type => $templates) { if (empty($templates)) { continue; } $this->filter->add("theme_{$post_type}_templates", function ($registered) use ($templates) { return array_merge($registered, $templates); }); } }
php
public function register() { foreach ($this->templates as $post_type => $templates) { if (empty($templates)) { continue; } $this->filter->add("theme_{$post_type}_templates", function ($registered) use ($templates) { return array_merge($registered, $templates); }); } }
[ "public", "function", "register", "(", ")", "{", "foreach", "(", "$", "this", "->", "templates", "as", "$", "post_type", "=>", "$", "templates", ")", "{", "if", "(", "empty", "(", "$", "templates", ")", ")", "{", "continue", ";", "}", "$", "this", "->", "filter", "->", "add", "(", "\"theme_{$post_type}_templates\"", ",", "function", "(", "$", "registered", ")", "use", "(", "$", "templates", ")", "{", "return", "array_merge", "(", "$", "registered", ",", "$", "templates", ")", ";", "}", ")", ";", "}", "}" ]
Register theme templates.
[ "Register", "theme", "templates", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Theme/Templates.php#L100-L111
train
themosis/framework
src/Forms/Fields/Types/BaseType.php
BaseType.getDefaultOptions
public function getDefaultOptions(): array { // Setup default validation rules. $this->defaultOptions['rules'] = $this->rules; // Setup default messages. $this->defaultOptions['messages'] = $this->messages; // Setup default placeholder. $this->defaultOptions['placeholder'] = $this->placeholder ?? $this->getBaseName(); // Setup default label. $this->defaultOptions['label'] = $this->label ?? ucfirst(str_replace(['-', '_'], ' ', $this->getBaseName())); return $this->defaultOptions; }
php
public function getDefaultOptions(): array { // Setup default validation rules. $this->defaultOptions['rules'] = $this->rules; // Setup default messages. $this->defaultOptions['messages'] = $this->messages; // Setup default placeholder. $this->defaultOptions['placeholder'] = $this->placeholder ?? $this->getBaseName(); // Setup default label. $this->defaultOptions['label'] = $this->label ?? ucfirst(str_replace(['-', '_'], ' ', $this->getBaseName())); return $this->defaultOptions; }
[ "public", "function", "getDefaultOptions", "(", ")", ":", "array", "{", "// Setup default validation rules.", "$", "this", "->", "defaultOptions", "[", "'rules'", "]", "=", "$", "this", "->", "rules", ";", "// Setup default messages.", "$", "this", "->", "defaultOptions", "[", "'messages'", "]", "=", "$", "this", "->", "messages", ";", "// Setup default placeholder.", "$", "this", "->", "defaultOptions", "[", "'placeholder'", "]", "=", "$", "this", "->", "placeholder", "??", "$", "this", "->", "getBaseName", "(", ")", ";", "// Setup default label.", "$", "this", "->", "defaultOptions", "[", "'label'", "]", "=", "$", "this", "->", "label", "??", "ucfirst", "(", "str_replace", "(", "[", "'-'", ",", "'_'", "]", ",", "' '", ",", "$", "this", "->", "getBaseName", "(", ")", ")", ")", ";", "return", "$", "this", "->", "defaultOptions", ";", "}" ]
Return the list of default options. @return array
[ "Return", "the", "list", "of", "default", "options", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/BaseType.php#L216-L231
train
themosis/framework
src/Forms/Fields/Types/BaseType.php
BaseType.getOptions
public function getOptions(array $excludes = null): array { if (! is_null($excludes)) { return array_filter($this->options, function ($key) use ($excludes) { return ! in_array($key, $excludes, true); }, ARRAY_FILTER_USE_KEY); } return $this->options; }
php
public function getOptions(array $excludes = null): array { if (! is_null($excludes)) { return array_filter($this->options, function ($key) use ($excludes) { return ! in_array($key, $excludes, true); }, ARRAY_FILTER_USE_KEY); } return $this->options; }
[ "public", "function", "getOptions", "(", "array", "$", "excludes", "=", "null", ")", ":", "array", "{", "if", "(", "!", "is_null", "(", "$", "excludes", ")", ")", "{", "return", "array_filter", "(", "$", "this", "->", "options", ",", "function", "(", "$", "key", ")", "use", "(", "$", "excludes", ")", "{", "return", "!", "in_array", "(", "$", "key", ",", "$", "excludes", ",", "true", ")", ";", "}", ",", "ARRAY_FILTER_USE_KEY", ")", ";", "}", "return", "$", "this", "->", "options", ";", "}" ]
Return field options. @param array $excludes @return array
[ "Return", "field", "options", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/BaseType.php#L333-L342
train
themosis/framework
src/Forms/Fields/Types/BaseType.php
BaseType.render
public function render(): string { $view = $this->viewFactory->make($this->getView(), $this->getFieldData()); // Indicates that the form has been rendered at least once. // Then return its content. $this->rendered = true; return $view->render(); }
php
public function render(): string { $view = $this->viewFactory->make($this->getView(), $this->getFieldData()); // Indicates that the form has been rendered at least once. // Then return its content. $this->rendered = true; return $view->render(); }
[ "public", "function", "render", "(", ")", ":", "string", "{", "$", "view", "=", "$", "this", "->", "viewFactory", "->", "make", "(", "$", "this", "->", "getView", "(", ")", ",", "$", "this", "->", "getFieldData", "(", ")", ")", ";", "// Indicates that the form has been rendered at least once.", "// Then return its content.", "$", "this", "->", "rendered", "=", "true", ";", "return", "$", "view", "->", "render", "(", ")", ";", "}" ]
Output the entity as HTML. @return string
[ "Output", "the", "entity", "as", "HTML", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/BaseType.php#L522-L531
train
themosis/framework
src/Forms/Fields/Types/BaseType.php
BaseType.getView
public function getView(bool $prefixed = true): string { if ($prefixed && ! is_null($theme = $this->getOption('theme'))) { return $this->buildViewPath($theme, $this->view); } return $this->view; }
php
public function getView(bool $prefixed = true): string { if ($prefixed && ! is_null($theme = $this->getOption('theme'))) { return $this->buildViewPath($theme, $this->view); } return $this->view; }
[ "public", "function", "getView", "(", "bool", "$", "prefixed", "=", "true", ")", ":", "string", "{", "if", "(", "$", "prefixed", "&&", "!", "is_null", "(", "$", "theme", "=", "$", "this", "->", "getOption", "(", "'theme'", ")", ")", ")", "{", "return", "$", "this", "->", "buildViewPath", "(", "$", "theme", ",", "$", "this", "->", "view", ")", ";", "}", "return", "$", "this", "->", "view", ";", "}" ]
Return the view instance used by the entity. @param bool $prefixed @return string
[ "Return", "the", "view", "instance", "used", "by", "the", "entity", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/BaseType.php#L566-L573
train
themosis/framework
src/Forms/Fields/Types/BaseType.php
BaseType.setValue
public function setValue($value): FieldTypeInterface { $this->value = $this->transformer->transform($value); return $this; }
php
public function setValue($value): FieldTypeInterface { $this->value = $this->transformer->transform($value); return $this; }
[ "public", "function", "setValue", "(", "$", "value", ")", ":", "FieldTypeInterface", "{", "$", "this", "->", "value", "=", "$", "this", "->", "transformer", "->", "transform", "(", "$", "value", ")", ";", "return", "$", "this", ";", "}" ]
Set the value property of the field. @param array|string $value @return FieldTypeInterface
[ "Set", "the", "value", "property", "of", "the", "field", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/BaseType.php#L626-L631
train
themosis/framework
src/Forms/Fields/Types/BaseType.php
BaseType.getRawValue
public function getRawValue() { $value = $this->transformer->reverseTransform($this->value); if ($this->getOption('flush', false)) { return ''; } return $value; }
php
public function getRawValue() { $value = $this->transformer->reverseTransform($this->value); if ($this->getOption('flush', false)) { return ''; } return $value; }
[ "public", "function", "getRawValue", "(", ")", "{", "$", "value", "=", "$", "this", "->", "transformer", "->", "reverseTransform", "(", "$", "this", "->", "value", ")", ";", "if", "(", "$", "this", "->", "getOption", "(", "'flush'", ",", "false", ")", ")", "{", "return", "''", ";", "}", "return", "$", "value", ";", "}" ]
Retrieve the field "raw" value. @return mixed
[ "Retrieve", "the", "field", "raw", "value", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/BaseType.php#L654-L663
train
themosis/framework
src/Forms/Fields/Types/BaseType.php
BaseType.error
public function error(string $name = '', bool $first = false) { $errors = $this->errors(); if (empty($name)) { $name = $this->getName(); } if ($first) { return $errors->first($name); } return $errors->get($name); }
php
public function error(string $name = '', bool $first = false) { $errors = $this->errors(); if (empty($name)) { $name = $this->getName(); } if ($first) { return $errors->first($name); } return $errors->get($name); }
[ "public", "function", "error", "(", "string", "$", "name", "=", "''", ",", "bool", "$", "first", "=", "false", ")", "{", "$", "errors", "=", "$", "this", "->", "errors", "(", ")", ";", "if", "(", "empty", "(", "$", "name", ")", ")", "{", "$", "name", "=", "$", "this", "->", "getName", "(", ")", ";", "}", "if", "(", "$", "first", ")", "{", "return", "$", "errors", "->", "first", "(", "$", "name", ")", ";", "}", "return", "$", "errors", "->", "get", "(", "$", "name", ")", ";", "}" ]
Retrieve the field error messages. @param string $name @param bool $first @return string|array
[ "Retrieve", "the", "field", "error", "messages", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/BaseType.php#L701-L714
train
themosis/framework
src/Core/Exceptions/Handler.php
Handler.unauthenticated
protected function unauthenticated($request, AuthenticationException $e) { return $request->expectsJson() ? response()->json(['message' => $e->getMessage()], 401) : redirect()->guest($e->redirectTo() ?? route('login')); }
php
protected function unauthenticated($request, AuthenticationException $e) { return $request->expectsJson() ? response()->json(['message' => $e->getMessage()], 401) : redirect()->guest($e->redirectTo() ?? route('login')); }
[ "protected", "function", "unauthenticated", "(", "$", "request", ",", "AuthenticationException", "$", "e", ")", "{", "return", "$", "request", "->", "expectsJson", "(", ")", "?", "response", "(", ")", "->", "json", "(", "[", "'message'", "=>", "$", "e", "->", "getMessage", "(", ")", "]", ",", "401", ")", ":", "redirect", "(", ")", "->", "guest", "(", "$", "e", "->", "redirectTo", "(", ")", "??", "route", "(", "'login'", ")", ")", ";", "}" ]
Convert an authentication exception into a response. @param Request $request @param AuthenticationException $e @return Response
[ "Convert", "an", "authentication", "exception", "into", "a", "response", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Exceptions/Handler.php#L185-L190
train
themosis/framework
src/Core/Exceptions/Handler.php
Handler.convertExceptionToResponse
protected function convertExceptionToResponse(Exception $e) { $headers = $this->isHttpException($e) ? $e->getHeaders() : []; $statusCode = $this->isHttpException($e) ? $e->getStatusCode() : 500; try { $content = config('app.debug') && class_exists(Whoops::class) ? $this->renderExceptionWithWhoops($e) : $this->renderExceptionWithSymfony($e, config('app.debug')); } catch (Exception $e) { $content = $content ?? $this->renderExceptionWithSymfony($e, config('app.debug')); } return SymfonyResponse::create( $content, $statusCode, $headers ); }
php
protected function convertExceptionToResponse(Exception $e) { $headers = $this->isHttpException($e) ? $e->getHeaders() : []; $statusCode = $this->isHttpException($e) ? $e->getStatusCode() : 500; try { $content = config('app.debug') && class_exists(Whoops::class) ? $this->renderExceptionWithWhoops($e) : $this->renderExceptionWithSymfony($e, config('app.debug')); } catch (Exception $e) { $content = $content ?? $this->renderExceptionWithSymfony($e, config('app.debug')); } return SymfonyResponse::create( $content, $statusCode, $headers ); }
[ "protected", "function", "convertExceptionToResponse", "(", "Exception", "$", "e", ")", "{", "$", "headers", "=", "$", "this", "->", "isHttpException", "(", "$", "e", ")", "?", "$", "e", "->", "getHeaders", "(", ")", ":", "[", "]", ";", "$", "statusCode", "=", "$", "this", "->", "isHttpException", "(", "$", "e", ")", "?", "$", "e", "->", "getStatusCode", "(", ")", ":", "500", ";", "try", "{", "$", "content", "=", "config", "(", "'app.debug'", ")", "&&", "class_exists", "(", "Whoops", "::", "class", ")", "?", "$", "this", "->", "renderExceptionWithWhoops", "(", "$", "e", ")", ":", "$", "this", "->", "renderExceptionWithSymfony", "(", "$", "e", ",", "config", "(", "'app.debug'", ")", ")", ";", "}", "catch", "(", "Exception", "$", "e", ")", "{", "$", "content", "=", "$", "content", "??", "$", "this", "->", "renderExceptionWithSymfony", "(", "$", "e", ",", "config", "(", "'app.debug'", ")", ")", ";", "}", "return", "SymfonyResponse", "::", "create", "(", "$", "content", ",", "$", "statusCode", ",", "$", "headers", ")", ";", "}" ]
Convert an exception to a response instance. @param Exception $e @throws \Illuminate\Container\EntryNotFoundException @return \Symfony\Component\HttpFoundation\Response
[ "Convert", "an", "exception", "to", "a", "response", "instance", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Exceptions/Handler.php#L396-L414
train
themosis/framework
src/Core/Exceptions/Handler.php
Handler.renderExceptionWithWhoops
protected function renderExceptionWithWhoops(Exception $e) { return tap(new Whoops(), function ($whoops) { $whoops->pushHandler($this->whoopsHandler()); $whoops->writeToOutput(false); $whoops->allowQuit(false); })->handleException($e); }
php
protected function renderExceptionWithWhoops(Exception $e) { return tap(new Whoops(), function ($whoops) { $whoops->pushHandler($this->whoopsHandler()); $whoops->writeToOutput(false); $whoops->allowQuit(false); })->handleException($e); }
[ "protected", "function", "renderExceptionWithWhoops", "(", "Exception", "$", "e", ")", "{", "return", "tap", "(", "new", "Whoops", "(", ")", ",", "function", "(", "$", "whoops", ")", "{", "$", "whoops", "->", "pushHandler", "(", "$", "this", "->", "whoopsHandler", "(", ")", ")", ";", "$", "whoops", "->", "writeToOutput", "(", "false", ")", ";", "$", "whoops", "->", "allowQuit", "(", "false", ")", ";", "}", ")", "->", "handleException", "(", "$", "e", ")", ";", "}" ]
Render an exception using Whoops. @param Exception $e @return string
[ "Render", "an", "exception", "using", "Whoops", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Exceptions/Handler.php#L423-L430
train
themosis/framework
src/Core/Exceptions/Handler.php
Handler.whoopsHandler
protected function whoopsHandler() { return tap(new PrettyPageHandler(), function ($handler) { $files = new Filesystem(); $handler->handleUnconditionally(true); foreach (config('app.debug_blacklist', []) as $key => $secrets) { foreach ($secrets as $secret) { $handler->blacklist($key, $secret); } } if (config('app.editor', false)) { $handler->setEditor(config('app.editor')); } $handler->setApplicationPaths( array_flip(Arr::except( array_flip($files->directories(base_path())), [base_path('vendor')] )) ); }); }
php
protected function whoopsHandler() { return tap(new PrettyPageHandler(), function ($handler) { $files = new Filesystem(); $handler->handleUnconditionally(true); foreach (config('app.debug_blacklist', []) as $key => $secrets) { foreach ($secrets as $secret) { $handler->blacklist($key, $secret); } } if (config('app.editor', false)) { $handler->setEditor(config('app.editor')); } $handler->setApplicationPaths( array_flip(Arr::except( array_flip($files->directories(base_path())), [base_path('vendor')] )) ); }); }
[ "protected", "function", "whoopsHandler", "(", ")", "{", "return", "tap", "(", "new", "PrettyPageHandler", "(", ")", ",", "function", "(", "$", "handler", ")", "{", "$", "files", "=", "new", "Filesystem", "(", ")", ";", "$", "handler", "->", "handleUnconditionally", "(", "true", ")", ";", "foreach", "(", "config", "(", "'app.debug_blacklist'", ",", "[", "]", ")", "as", "$", "key", "=>", "$", "secrets", ")", "{", "foreach", "(", "$", "secrets", "as", "$", "secret", ")", "{", "$", "handler", "->", "blacklist", "(", "$", "key", ",", "$", "secret", ")", ";", "}", "}", "if", "(", "config", "(", "'app.editor'", ",", "false", ")", ")", "{", "$", "handler", "->", "setEditor", "(", "config", "(", "'app.editor'", ")", ")", ";", "}", "$", "handler", "->", "setApplicationPaths", "(", "array_flip", "(", "Arr", "::", "except", "(", "array_flip", "(", "$", "files", "->", "directories", "(", "base_path", "(", ")", ")", ")", ",", "[", "base_path", "(", "'vendor'", ")", "]", ")", ")", ")", ";", "}", ")", ";", "}" ]
Get the Whoops handler for the application. @return \Whoops\Handler\Handler
[ "Get", "the", "Whoops", "handler", "for", "the", "application", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Exceptions/Handler.php#L437-L460
train
themosis/framework
src/Core/Exceptions/Handler.php
Handler.context
protected function context() { try { return [ 'userId' => Auth::id(), 'email' => Auth::user() ? Auth::user()->email : null ]; } catch (Throwable $e) { return []; } }
php
protected function context() { try { return [ 'userId' => Auth::id(), 'email' => Auth::user() ? Auth::user()->email : null ]; } catch (Throwable $e) { return []; } }
[ "protected", "function", "context", "(", ")", "{", "try", "{", "return", "[", "'userId'", "=>", "Auth", "::", "id", "(", ")", ",", "'email'", "=>", "Auth", "::", "user", "(", ")", "?", "Auth", "::", "user", "(", ")", "->", "email", ":", "null", "]", ";", "}", "catch", "(", "Throwable", "$", "e", ")", "{", "return", "[", "]", ";", "}", "}" ]
Get the default context variables for logging. @return array
[ "Get", "the", "default", "context", "variables", "for", "logging", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Exceptions/Handler.php#L508-L518
train
themosis/framework
src/Ajax/Ajax.php
Ajax.listen
public function listen($action, $callback, $logged = 'both'): AjaxInterface { // Front-end ajax for non-logged users // Set $logged to false if ($logged === false || $logged === 'no') { $this->action->add('wp_ajax_nopriv_'.$action, $callback); } // Front-end and back-end ajax for logged users if ($logged === true || $logged === 'yes') { $this->action->add('wp_ajax_'.$action, $callback); } // Front-end and back-end for both logged in or out users if ($logged === 'both') { $this->action->add([ 'wp_ajax_nopriv_'.$action, 'wp_ajax_'.$action ], $callback); } return $this; }
php
public function listen($action, $callback, $logged = 'both'): AjaxInterface { // Front-end ajax for non-logged users // Set $logged to false if ($logged === false || $logged === 'no') { $this->action->add('wp_ajax_nopriv_'.$action, $callback); } // Front-end and back-end ajax for logged users if ($logged === true || $logged === 'yes') { $this->action->add('wp_ajax_'.$action, $callback); } // Front-end and back-end for both logged in or out users if ($logged === 'both') { $this->action->add([ 'wp_ajax_nopriv_'.$action, 'wp_ajax_'.$action ], $callback); } return $this; }
[ "public", "function", "listen", "(", "$", "action", ",", "$", "callback", ",", "$", "logged", "=", "'both'", ")", ":", "AjaxInterface", "{", "// Front-end ajax for non-logged users", "// Set $logged to false", "if", "(", "$", "logged", "===", "false", "||", "$", "logged", "===", "'no'", ")", "{", "$", "this", "->", "action", "->", "add", "(", "'wp_ajax_nopriv_'", ".", "$", "action", ",", "$", "callback", ")", ";", "}", "// Front-end and back-end ajax for logged users", "if", "(", "$", "logged", "===", "true", "||", "$", "logged", "===", "'yes'", ")", "{", "$", "this", "->", "action", "->", "add", "(", "'wp_ajax_'", ".", "$", "action", ",", "$", "callback", ")", ";", "}", "// Front-end and back-end for both logged in or out users", "if", "(", "$", "logged", "===", "'both'", ")", "{", "$", "this", "->", "action", "->", "add", "(", "[", "'wp_ajax_nopriv_'", ".", "$", "action", ",", "'wp_ajax_'", ".", "$", "action", "]", ",", "$", "callback", ")", ";", "}", "return", "$", "this", ";", "}" ]
Listen to AJAX API calls. @param string $action The AJAX action name. @param \Closure|string $callback A callback function name, a closure or a string defining a class and its method. @param string|bool $logged true, false or 'both' type of users. @return AjaxInterface
[ "Listen", "to", "AJAX", "API", "calls", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Ajax/Ajax.php#L30-L52
train
themosis/framework
src/Core/Providers/CoreServiceProvider.php
CoreServiceProvider.boot
public function boot() { if ($this->app->runningInConsole()) { $this->publishes([ __DIR__.'/../../../dist' => web_path('dist') ], 'themosis'); $this->publishes([ __DIR__.'/../Exceptions/views' => resource_path('views/errors/') ], 'themosis-errors'); } }
php
public function boot() { if ($this->app->runningInConsole()) { $this->publishes([ __DIR__.'/../../../dist' => web_path('dist') ], 'themosis'); $this->publishes([ __DIR__.'/../Exceptions/views' => resource_path('views/errors/') ], 'themosis-errors'); } }
[ "public", "function", "boot", "(", ")", "{", "if", "(", "$", "this", "->", "app", "->", "runningInConsole", "(", ")", ")", "{", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../../../dist'", "=>", "web_path", "(", "'dist'", ")", "]", ",", "'themosis'", ")", ";", "$", "this", "->", "publishes", "(", "[", "__DIR__", ".", "'/../Exceptions/views'", "=>", "resource_path", "(", "'views/errors/'", ")", "]", ",", "'themosis-errors'", ")", ";", "}", "}" ]
Publish core assets.
[ "Publish", "core", "assets", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Core/Providers/CoreServiceProvider.php#L54-L65
train
themosis/framework
src/View/ViewServiceProvider.php
ViewServiceProvider.registerTwigEnvironment
public function registerTwigEnvironment() { $this->app->singleton('twig', function ($app) { $twig = new \Twig_Environment( $app['twig.loader'], [ 'auto_reload' => true, 'cache' => $app['config']['view.twig'] ] ); // Add Twig Debug Extension $twig->addExtension(new \Twig_Extension_Debug()); // Enable debug. if ($app['config']['app.debug']) { $twig->enableDebug(); } // Add WordPress helpers extension. $twig->addExtension(new WordPress()); return $twig; }); }
php
public function registerTwigEnvironment() { $this->app->singleton('twig', function ($app) { $twig = new \Twig_Environment( $app['twig.loader'], [ 'auto_reload' => true, 'cache' => $app['config']['view.twig'] ] ); // Add Twig Debug Extension $twig->addExtension(new \Twig_Extension_Debug()); // Enable debug. if ($app['config']['app.debug']) { $twig->enableDebug(); } // Add WordPress helpers extension. $twig->addExtension(new WordPress()); return $twig; }); }
[ "public", "function", "registerTwigEnvironment", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'twig'", ",", "function", "(", "$", "app", ")", "{", "$", "twig", "=", "new", "\\", "Twig_Environment", "(", "$", "app", "[", "'twig.loader'", "]", ",", "[", "'auto_reload'", "=>", "true", ",", "'cache'", "=>", "$", "app", "[", "'config'", "]", "[", "'view.twig'", "]", "]", ")", ";", "// Add Twig Debug Extension", "$", "twig", "->", "addExtension", "(", "new", "\\", "Twig_Extension_Debug", "(", ")", ")", ";", "// Enable debug.", "if", "(", "$", "app", "[", "'config'", "]", "[", "'app.debug'", "]", ")", "{", "$", "twig", "->", "enableDebug", "(", ")", ";", "}", "// Add WordPress helpers extension.", "$", "twig", "->", "addExtension", "(", "new", "WordPress", "(", ")", ")", ";", "return", "$", "twig", ";", "}", ")", ";", "}" ]
Register Twig Environment.
[ "Register", "Twig", "Environment", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/View/ViewServiceProvider.php#L46-L70
train
themosis/framework
src/View/ViewServiceProvider.php
ViewServiceProvider.registerTwigEngine
public function registerTwigEngine() { /** @var Factory $factory */ $factory = $this->app['view']; $factory->addExtension('twig', 'twig', function () { return new Twig($this->app['twig'], $this->app['view.finder']); }); }
php
public function registerTwigEngine() { /** @var Factory $factory */ $factory = $this->app['view']; $factory->addExtension('twig', 'twig', function () { return new Twig($this->app['twig'], $this->app['view.finder']); }); }
[ "public", "function", "registerTwigEngine", "(", ")", "{", "/** @var Factory $factory */", "$", "factory", "=", "$", "this", "->", "app", "[", "'view'", "]", ";", "$", "factory", "->", "addExtension", "(", "'twig'", ",", "'twig'", ",", "function", "(", ")", "{", "return", "new", "Twig", "(", "$", "this", "->", "app", "[", "'twig'", "]", ",", "$", "this", "->", "app", "[", "'view.finder'", "]", ")", ";", "}", ")", ";", "}" ]
Register the Twig engine implementation.
[ "Register", "the", "Twig", "engine", "implementation", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/View/ViewServiceProvider.php#L75-L82
train
themosis/framework
src/Forms/Fields/Types/CollectionType.php
CollectionType.setDefaultOptions
protected function setDefaultOptions(): array { // A limit of "0" means no-limit. $default = [ 'limit' => 0, 'type' => ['image', 'application'] ]; if (function_exists('_x')) { $default['l10n'] = [ 'add' => _x('Add Media', 'field', Application::TEXTDOMAIN), 'button' => _x('Insert', 'field', Application::TEXTDOMAIN), 'remove' => _x('Remove Selected', 'field', Application::TEXTDOMAIN), 'title' => _x('Insert Multiple Media', 'field', Application::TEXTDOMAIN) ]; } return array_merge($this->defaultOptions, $default); }
php
protected function setDefaultOptions(): array { // A limit of "0" means no-limit. $default = [ 'limit' => 0, 'type' => ['image', 'application'] ]; if (function_exists('_x')) { $default['l10n'] = [ 'add' => _x('Add Media', 'field', Application::TEXTDOMAIN), 'button' => _x('Insert', 'field', Application::TEXTDOMAIN), 'remove' => _x('Remove Selected', 'field', Application::TEXTDOMAIN), 'title' => _x('Insert Multiple Media', 'field', Application::TEXTDOMAIN) ]; } return array_merge($this->defaultOptions, $default); }
[ "protected", "function", "setDefaultOptions", "(", ")", ":", "array", "{", "// A limit of \"0\" means no-limit.", "$", "default", "=", "[", "'limit'", "=>", "0", ",", "'type'", "=>", "[", "'image'", ",", "'application'", "]", "]", ";", "if", "(", "function_exists", "(", "'_x'", ")", ")", "{", "$", "default", "[", "'l10n'", "]", "=", "[", "'add'", "=>", "_x", "(", "'Add Media'", ",", "'field'", ",", "Application", "::", "TEXTDOMAIN", ")", ",", "'button'", "=>", "_x", "(", "'Insert'", ",", "'field'", ",", "Application", "::", "TEXTDOMAIN", ")", ",", "'remove'", "=>", "_x", "(", "'Remove Selected'", ",", "'field'", ",", "Application", "::", "TEXTDOMAIN", ")", ",", "'title'", "=>", "_x", "(", "'Insert Multiple Media'", ",", "'field'", ",", "Application", "::", "TEXTDOMAIN", ")", "]", ";", "}", "return", "array_merge", "(", "$", "this", "->", "defaultOptions", ",", "$", "default", ")", ";", "}" ]
Set field default options values. @return array
[ "Set", "field", "default", "options", "values", "." ]
9931cdda709b94cc712495acf93211b6fa9d23a7
https://github.com/themosis/framework/blob/9931cdda709b94cc712495acf93211b6fa9d23a7/src/Forms/Fields/Types/CollectionType.php#L64-L82
train