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
thephpleague/json-guard
src/Validator.php
Validator.validate
private function validate() { if ($this->hasValidated) { return; } $this->checkDepth(); foreach ($this->schema as $rule => $parameter) { $this->currentKeyword = $rule; $this->currentParameter = $parameter; $this->mergeErrors($this->validateRule($rule, $parameter)); $this->currentKeyword = $this->currentParameter = null; } $this->hasValidated = true; }
php
private function validate() { if ($this->hasValidated) { return; } $this->checkDepth(); foreach ($this->schema as $rule => $parameter) { $this->currentKeyword = $rule; $this->currentParameter = $parameter; $this->mergeErrors($this->validateRule($rule, $parameter)); $this->currentKeyword = $this->currentParameter = null; } $this->hasValidated = true; }
[ "private", "function", "validate", "(", ")", "{", "if", "(", "$", "this", "->", "hasValidated", ")", "{", "return", ";", "}", "$", "this", "->", "checkDepth", "(", ")", ";", "foreach", "(", "$", "this", "->", "schema", "as", "$", "rule", "=>", "$",...
Validate the data and collect the errors.
[ "Validate", "the", "data", "and", "collect", "the", "errors", "." ]
d03dad6288f3b044f83edaaa3a1adcf71f8c757b
https://github.com/thephpleague/json-guard/blob/d03dad6288f3b044f83edaaa3a1adcf71f8c757b/src/Validator.php#L227-L243
train
thephpleague/json-guard
src/Validator.php
Validator.validateRule
private function validateRule($keyword, $parameter) { if (!$this->ruleSet->has($keyword)) { return null; } return $this->ruleSet->get($keyword)->validate($this->data, $parameter, $this); }
php
private function validateRule($keyword, $parameter) { if (!$this->ruleSet->has($keyword)) { return null; } return $this->ruleSet->get($keyword)->validate($this->data, $parameter, $this); }
[ "private", "function", "validateRule", "(", "$", "keyword", ",", "$", "parameter", ")", "{", "if", "(", "!", "$", "this", "->", "ruleSet", "->", "has", "(", "$", "keyword", ")", ")", "{", "return", "null", ";", "}", "return", "$", "this", "->", "ru...
Validate the data using the given rule and parameter. @param string $keyword @param mixed $parameter @return null|ValidationError|ValidationError[]
[ "Validate", "the", "data", "using", "the", "given", "rule", "and", "parameter", "." ]
d03dad6288f3b044f83edaaa3a1adcf71f8c757b
https://github.com/thephpleague/json-guard/blob/d03dad6288f3b044f83edaaa3a1adcf71f8c757b/src/Validator.php#L268-L275
train
thephpleague/json-guard
src/Validator.php
Validator.mergeErrors
private function mergeErrors($errors) { if (is_null($errors)) { return; } $errors = is_array($errors) ? $errors : [$errors]; $this->errors = array_merge($this->errors, $errors); }
php
private function mergeErrors($errors) { if (is_null($errors)) { return; } $errors = is_array($errors) ? $errors : [$errors]; $this->errors = array_merge($this->errors, $errors); }
[ "private", "function", "mergeErrors", "(", "$", "errors", ")", "{", "if", "(", "is_null", "(", "$", "errors", ")", ")", "{", "return", ";", "}", "$", "errors", "=", "is_array", "(", "$", "errors", ")", "?", "$", "errors", ":", "[", "$", "errors", ...
Merge the errors with our error collection. @param ValidationError[]|ValidationError|null $errors
[ "Merge", "the", "errors", "with", "our", "error", "collection", "." ]
d03dad6288f3b044f83edaaa3a1adcf71f8c757b
https://github.com/thephpleague/json-guard/blob/d03dad6288f3b044f83edaaa3a1adcf71f8c757b/src/Validator.php#L282-L290
train
thephpleague/json-guard
src/ValidationError.php
ValidationError.getMessage
public function getMessage() { if ($this->interpolatedMessage === null) { $this->interpolatedMessage = $this->interpolate($this->message, $this->getContext()); } return $this->interpolatedMessage; }
php
public function getMessage() { if ($this->interpolatedMessage === null) { $this->interpolatedMessage = $this->interpolate($this->message, $this->getContext()); } return $this->interpolatedMessage; }
[ "public", "function", "getMessage", "(", ")", "{", "if", "(", "$", "this", "->", "interpolatedMessage", "===", "null", ")", "{", "$", "this", "->", "interpolatedMessage", "=", "$", "this", "->", "interpolate", "(", "$", "this", "->", "message", ",", "$",...
Get the human readable error message for this error. @return string
[ "Get", "the", "human", "readable", "error", "message", "for", "this", "error", "." ]
d03dad6288f3b044f83edaaa3a1adcf71f8c757b
https://github.com/thephpleague/json-guard/blob/d03dad6288f3b044f83edaaa3a1adcf71f8c757b/src/ValidationError.php#L89-L96
train
thephpleague/json-guard
src/ValidationError.php
ValidationError.getContext
public function getContext() { if ($this->context === null) { $this->context = array_map( 'League\JsonGuard\as_string', [ self::KEYWORD => $this->keyword, self::PARAMETER => $this->parameter, self::DATA => $this->data, self::DATA_PATH => $this->dataPath, self::SCHEMA => $this->schema, self::SCHEMA_PATH => $this->schemaPath, self::CAUSE => $this->getCause(), ] ); } return $this->context; }
php
public function getContext() { if ($this->context === null) { $this->context = array_map( 'League\JsonGuard\as_string', [ self::KEYWORD => $this->keyword, self::PARAMETER => $this->parameter, self::DATA => $this->data, self::DATA_PATH => $this->dataPath, self::SCHEMA => $this->schema, self::SCHEMA_PATH => $this->schemaPath, self::CAUSE => $this->getCause(), ] ); } return $this->context; }
[ "public", "function", "getContext", "(", ")", "{", "if", "(", "$", "this", "->", "context", "===", "null", ")", "{", "$", "this", "->", "context", "=", "array_map", "(", "'League\\JsonGuard\\as_string'", ",", "[", "self", "::", "KEYWORD", "=>", "$", "thi...
Get the context that applied to the failed assertion. @return string[]
[ "Get", "the", "context", "that", "applied", "to", "the", "failed", "assertion", "." ]
d03dad6288f3b044f83edaaa3a1adcf71f8c757b
https://github.com/thephpleague/json-guard/blob/d03dad6288f3b044f83edaaa3a1adcf71f8c757b/src/ValidationError.php#L178-L196
train
thephpleague/json-guard
src/RuleSet/RuleSetContainer.php
RuleSetContainer.set
public function set($keyword, $factory) { if (!(is_string($factory) || $factory instanceof \Closure)) { throw new \InvalidArgumentException( sprintf('Expected a string or Closure, got %s', gettype($keyword)) ); } $this->rules[$keyword] = function ($container) use ($factory) { static $object; if (is_null($object)) { $object = is_string($factory) ? new $factory() : $factory($container); } return $object; }; }
php
public function set($keyword, $factory) { if (!(is_string($factory) || $factory instanceof \Closure)) { throw new \InvalidArgumentException( sprintf('Expected a string or Closure, got %s', gettype($keyword)) ); } $this->rules[$keyword] = function ($container) use ($factory) { static $object; if (is_null($object)) { $object = is_string($factory) ? new $factory() : $factory($container); } return $object; }; }
[ "public", "function", "set", "(", "$", "keyword", ",", "$", "factory", ")", "{", "if", "(", "!", "(", "is_string", "(", "$", "factory", ")", "||", "$", "factory", "instanceof", "\\", "Closure", ")", ")", "{", "throw", "new", "\\", "InvalidArgumentExcep...
Adds a rule to the container. @param string $keyword Identifier of the entry. @param \Closure|string $factory The closure to invoke when this entry is resolved or the FQCN. The closure will be given this container as the only argument when invoked.
[ "Adds", "a", "rule", "to", "the", "container", "." ]
d03dad6288f3b044f83edaaa3a1adcf71f8c757b
https://github.com/thephpleague/json-guard/blob/d03dad6288f3b044f83edaaa3a1adcf71f8c757b/src/RuleSet/RuleSetContainer.php#L50-L67
train
bjyoungblood/BjyAuthorize
src/BjyAuthorize/Guard/Controller.php
Controller.getResourceName
public function getResourceName($controller, $action = null) { if (isset($action)) { return sprintf('controller/%s:%s', $controller, strtolower($action)); } return sprintf('controller/%s', $controller); }
php
public function getResourceName($controller, $action = null) { if (isset($action)) { return sprintf('controller/%s:%s', $controller, strtolower($action)); } return sprintf('controller/%s', $controller); }
[ "public", "function", "getResourceName", "(", "$", "controller", ",", "$", "action", "=", "null", ")", "{", "if", "(", "isset", "(", "$", "action", ")", ")", "{", "return", "sprintf", "(", "'controller/%s:%s'", ",", "$", "controller", ",", "strtolower", ...
Retrieves the resource name for a given controller @param string $controller @param string $action @return string
[ "Retrieves", "the", "resource", "name", "for", "a", "given", "controller" ]
e64a20b8bfc2edbc5998626be9f30a357e3d1204
https://github.com/bjyoungblood/BjyAuthorize/blob/e64a20b8bfc2edbc5998626be9f30a357e3d1204/src/BjyAuthorize/Guard/Controller.php#L60-L67
train
bjyoungblood/BjyAuthorize
src/BjyAuthorize/Provider/Identity/AuthenticationIdentityProvider.php
AuthenticationIdentityProvider.setDefaultRole
public function setDefaultRole($defaultRole) { if (! ($defaultRole instanceof RoleInterface || is_string($defaultRole))) { throw InvalidRoleException::invalidRoleInstance($defaultRole); } $this->defaultRole = $defaultRole; }
php
public function setDefaultRole($defaultRole) { if (! ($defaultRole instanceof RoleInterface || is_string($defaultRole))) { throw InvalidRoleException::invalidRoleInstance($defaultRole); } $this->defaultRole = $defaultRole; }
[ "public", "function", "setDefaultRole", "(", "$", "defaultRole", ")", "{", "if", "(", "!", "(", "$", "defaultRole", "instanceof", "RoleInterface", "||", "is_string", "(", "$", "defaultRole", ")", ")", ")", "{", "throw", "InvalidRoleException", "::", "invalidRo...
Set the rule that's used if you're not authenticated @param $defaultRole @throws \BjyAuthorize\Exception\InvalidRoleException
[ "Set", "the", "rule", "that", "s", "used", "if", "you", "re", "not", "authenticated" ]
e64a20b8bfc2edbc5998626be9f30a357e3d1204
https://github.com/bjyoungblood/BjyAuthorize/blob/e64a20b8bfc2edbc5998626be9f30a357e3d1204/src/BjyAuthorize/Provider/Identity/AuthenticationIdentityProvider.php#L83-L90
train
bjyoungblood/BjyAuthorize
src/BjyAuthorize/Provider/Identity/AuthenticationIdentityProvider.php
AuthenticationIdentityProvider.setAuthenticatedRole
public function setAuthenticatedRole($authenticatedRole) { if (! ($authenticatedRole instanceof RoleInterface || is_string($authenticatedRole))) { throw InvalidRoleException::invalidRoleInstance($authenticatedRole); } $this->authenticatedRole = $authenticatedRole; }
php
public function setAuthenticatedRole($authenticatedRole) { if (! ($authenticatedRole instanceof RoleInterface || is_string($authenticatedRole))) { throw InvalidRoleException::invalidRoleInstance($authenticatedRole); } $this->authenticatedRole = $authenticatedRole; }
[ "public", "function", "setAuthenticatedRole", "(", "$", "authenticatedRole", ")", "{", "if", "(", "!", "(", "$", "authenticatedRole", "instanceof", "RoleInterface", "||", "is_string", "(", "$", "authenticatedRole", ")", ")", ")", "{", "throw", "InvalidRoleExceptio...
Set the role that is used if you're authenticated and the identity provides no role @param string|\Zend\Permissions\Acl\Role\RoleInterface $authenticatedRole @throws \BjyAuthorize\Exception\InvalidRoleException
[ "Set", "the", "role", "that", "is", "used", "if", "you", "re", "authenticated", "and", "the", "identity", "provides", "no", "role" ]
e64a20b8bfc2edbc5998626be9f30a357e3d1204
https://github.com/bjyoungblood/BjyAuthorize/blob/e64a20b8bfc2edbc5998626be9f30a357e3d1204/src/BjyAuthorize/Provider/Identity/AuthenticationIdentityProvider.php#L110-L117
train
bjyoungblood/BjyAuthorize
src/BjyAuthorize/View/UnauthorizedStrategy.php
UnauthorizedStrategy.onDispatchError
public function onDispatchError(MvcEvent $event) { // Do nothing if the result is a response object $result = $event->getResult(); $response = $event->getResponse(); if ($result instanceof Response || ($response && ! $response instanceof HttpResponse)) { return; } // Common view variables $viewVariables = array( 'error' => $event->getParam('error'), 'identity' => $event->getParam('identity'), ); switch ($event->getError()) { case Controller::ERROR: $viewVariables['controller'] = $event->getParam('controller'); $viewVariables['action'] = $event->getParam('action'); break; case Route::ERROR: $viewVariables['route'] = $event->getParam('route'); break; case Application::ERROR_EXCEPTION: if (!($event->getParam('exception') instanceof UnAuthorizedException)) { return; } $viewVariables['reason'] = $event->getParam('exception')->getMessage(); $viewVariables['error'] = 'error-unauthorized'; break; default: /* * do nothing if there is no error in the event or the error * does not match one of our predefined errors (we don't want * our 403 template to handle other types of errors) */ return; } $model = new ViewModel($viewVariables); $response = $response ?: new HttpResponse(); $model->setTemplate($this->getTemplate()); $event->getViewModel()->addChild($model); $response->setStatusCode(403); $event->setResponse($response); }
php
public function onDispatchError(MvcEvent $event) { // Do nothing if the result is a response object $result = $event->getResult(); $response = $event->getResponse(); if ($result instanceof Response || ($response && ! $response instanceof HttpResponse)) { return; } // Common view variables $viewVariables = array( 'error' => $event->getParam('error'), 'identity' => $event->getParam('identity'), ); switch ($event->getError()) { case Controller::ERROR: $viewVariables['controller'] = $event->getParam('controller'); $viewVariables['action'] = $event->getParam('action'); break; case Route::ERROR: $viewVariables['route'] = $event->getParam('route'); break; case Application::ERROR_EXCEPTION: if (!($event->getParam('exception') instanceof UnAuthorizedException)) { return; } $viewVariables['reason'] = $event->getParam('exception')->getMessage(); $viewVariables['error'] = 'error-unauthorized'; break; default: /* * do nothing if there is no error in the event or the error * does not match one of our predefined errors (we don't want * our 403 template to handle other types of errors) */ return; } $model = new ViewModel($viewVariables); $response = $response ?: new HttpResponse(); $model->setTemplate($this->getTemplate()); $event->getViewModel()->addChild($model); $response->setStatusCode(403); $event->setResponse($response); }
[ "public", "function", "onDispatchError", "(", "MvcEvent", "$", "event", ")", "{", "// Do nothing if the result is a response object", "$", "result", "=", "$", "event", "->", "getResult", "(", ")", ";", "$", "response", "=", "$", "event", "->", "getResponse", "("...
Callback used when a dispatch error occurs. Modifies the response object with an according error if the application event contains an exception related with authorization. @param MvcEvent $event @return void
[ "Callback", "used", "when", "a", "dispatch", "error", "occurs", ".", "Modifies", "the", "response", "object", "with", "an", "according", "error", "if", "the", "application", "event", "contains", "an", "exception", "related", "with", "authorization", "." ]
e64a20b8bfc2edbc5998626be9f30a357e3d1204
https://github.com/bjyoungblood/BjyAuthorize/blob/e64a20b8bfc2edbc5998626be9f30a357e3d1204/src/BjyAuthorize/View/UnauthorizedStrategy.php#L93-L142
train
bjyoungblood/BjyAuthorize
src/BjyAuthorize/Service/CacheKeyGeneratorFactory.php
CacheKeyGeneratorFactory.createService
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('BjyAuthorize\Config'); $cacheKey = empty($config['cache_key']) ? 'bjyauthorize_acl' : (string) $config['cache_key']; return function () use ($cacheKey) { return $cacheKey; }; }
php
public function createService(ServiceLocatorInterface $serviceLocator) { $config = $serviceLocator->get('BjyAuthorize\Config'); $cacheKey = empty($config['cache_key']) ? 'bjyauthorize_acl' : (string) $config['cache_key']; return function () use ($cacheKey) { return $cacheKey; }; }
[ "public", "function", "createService", "(", "ServiceLocatorInterface", "$", "serviceLocator", ")", "{", "$", "config", "=", "$", "serviceLocator", "->", "get", "(", "'BjyAuthorize\\Config'", ")", ";", "$", "cacheKey", "=", "empty", "(", "$", "config", "[", "'c...
Create a cache key @param ServiceLocatorInterface $serviceLocator @return callable
[ "Create", "a", "cache", "key" ]
e64a20b8bfc2edbc5998626be9f30a357e3d1204
https://github.com/bjyoungblood/BjyAuthorize/blob/e64a20b8bfc2edbc5998626be9f30a357e3d1204/src/BjyAuthorize/Service/CacheKeyGeneratorFactory.php#L27-L35
train
bjyoungblood/BjyAuthorize
src/BjyAuthorize/Service/Authorize.php
Authorize.load
public function load() { if (null === $this->loaded) { return; } $this->loaded = null; /** @var $cache StorageInterface */ $cache = $this->serviceLocator->get('BjyAuthorize\Cache'); /** @var $cacheKeyGenerator callable */ $cacheKeyGenerator = $this->serviceLocator->get('BjyAuthorize\CacheKeyGenerator'); $cacheKey = $cacheKeyGenerator(); $success = false; $this->acl = $cache->getItem($cacheKey, $success); if (!($this->acl instanceof Acl) || !$success) { $this->loadAcl(); $cache->setItem($cacheKey, $this->acl); } $this->setIdentityProvider($this->serviceLocator->get('BjyAuthorize\Provider\Identity\ProviderInterface')); $parentRoles = $this->getIdentityProvider()->getIdentityRoles(); $this->acl->addRole($this->getIdentity(), $parentRoles); }
php
public function load() { if (null === $this->loaded) { return; } $this->loaded = null; /** @var $cache StorageInterface */ $cache = $this->serviceLocator->get('BjyAuthorize\Cache'); /** @var $cacheKeyGenerator callable */ $cacheKeyGenerator = $this->serviceLocator->get('BjyAuthorize\CacheKeyGenerator'); $cacheKey = $cacheKeyGenerator(); $success = false; $this->acl = $cache->getItem($cacheKey, $success); if (!($this->acl instanceof Acl) || !$success) { $this->loadAcl(); $cache->setItem($cacheKey, $this->acl); } $this->setIdentityProvider($this->serviceLocator->get('BjyAuthorize\Provider\Identity\ProviderInterface')); $parentRoles = $this->getIdentityProvider()->getIdentityRoles(); $this->acl->addRole($this->getIdentity(), $parentRoles); }
[ "public", "function", "load", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "loaded", ")", "{", "return", ";", "}", "$", "this", "->", "loaded", "=", "null", ";", "/** @var $cache StorageInterface */", "$", "cache", "=", "$", "this", "->"...
Initializes the service @internal @return void
[ "Initializes", "the", "service" ]
e64a20b8bfc2edbc5998626be9f30a357e3d1204
https://github.com/bjyoungblood/BjyAuthorize/blob/e64a20b8bfc2edbc5998626be9f30a357e3d1204/src/BjyAuthorize/Service/Authorize.php#L255-L283
train
bjyoungblood/BjyAuthorize
src/BjyAuthorize/Service/Authorize.php
Authorize.loadAcl
private function loadAcl() { $this->acl = new Acl(); foreach ($this->serviceLocator->get('BjyAuthorize\RoleProviders') as $provider) { $this->addRoleProvider($provider); } foreach ($this->serviceLocator->get('BjyAuthorize\ResourceProviders') as $provider) { $this->addResourceProvider($provider); } foreach ($this->serviceLocator->get('BjyAuthorize\RuleProviders') as $provider) { $this->addRuleProvider($provider); } foreach ($this->serviceLocator->get('BjyAuthorize\Guards') as $guard) { $this->addGuard($guard); } foreach ($this->roleProviders as $provider) { $this->addRoles($provider->getRoles()); } foreach ($this->resourceProviders as $provider) { $this->loadResource($provider->getResources(), null); } foreach ($this->ruleProviders as $provider) { $rules = $provider->getRules(); if (isset($rules['allow'])) { foreach ($rules['allow'] as $rule) { $this->loadRule($rule, static::TYPE_ALLOW); } } if (isset($rules['deny'])) { foreach ($rules['deny'] as $rule) { $this->loadRule($rule, static::TYPE_DENY); } } } }
php
private function loadAcl() { $this->acl = new Acl(); foreach ($this->serviceLocator->get('BjyAuthorize\RoleProviders') as $provider) { $this->addRoleProvider($provider); } foreach ($this->serviceLocator->get('BjyAuthorize\ResourceProviders') as $provider) { $this->addResourceProvider($provider); } foreach ($this->serviceLocator->get('BjyAuthorize\RuleProviders') as $provider) { $this->addRuleProvider($provider); } foreach ($this->serviceLocator->get('BjyAuthorize\Guards') as $guard) { $this->addGuard($guard); } foreach ($this->roleProviders as $provider) { $this->addRoles($provider->getRoles()); } foreach ($this->resourceProviders as $provider) { $this->loadResource($provider->getResources(), null); } foreach ($this->ruleProviders as $provider) { $rules = $provider->getRules(); if (isset($rules['allow'])) { foreach ($rules['allow'] as $rule) { $this->loadRule($rule, static::TYPE_ALLOW); } } if (isset($rules['deny'])) { foreach ($rules['deny'] as $rule) { $this->loadRule($rule, static::TYPE_DENY); } } } }
[ "private", "function", "loadAcl", "(", ")", "{", "$", "this", "->", "acl", "=", "new", "Acl", "(", ")", ";", "foreach", "(", "$", "this", "->", "serviceLocator", "->", "get", "(", "'BjyAuthorize\\RoleProviders'", ")", "as", "$", "provider", ")", "{", "...
Initialize the Acl
[ "Initialize", "the", "Acl" ]
e64a20b8bfc2edbc5998626be9f30a357e3d1204
https://github.com/bjyoungblood/BjyAuthorize/blob/e64a20b8bfc2edbc5998626be9f30a357e3d1204/src/BjyAuthorize/Service/Authorize.php#L379-L421
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Columns.php
Columns.getColumnNames
public function getColumnNames() { $columns = array(); foreach ($this->childs as $column) { $columns[] = $column->getColumnName(); } return $columns; }
php
public function getColumnNames() { $columns = array(); foreach ($this->childs as $column) { $columns[] = $column->getColumnName(); } return $columns; }
[ "public", "function", "getColumnNames", "(", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "childs", "as", "$", "column", ")", "{", "$", "columns", "[", "]", "=", "$", "column", "->", "getColumnName", "(", ...
Get column names. @return array
[ "Get", "column", "names", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Columns.php#L83-L91
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Storage/Storage.php
Storage.getFile
public function getFile($filename) { $filename = $this->outDir.DIRECTORY_SEPARATOR.$filename; $this->mkdir(dirname($filename)); if (is_file($filename) && $this->backup) { @rename($filename, sprintf('%s.bak', $filename)); } return $filename; }
php
public function getFile($filename) { $filename = $this->outDir.DIRECTORY_SEPARATOR.$filename; $this->mkdir(dirname($filename)); if (is_file($filename) && $this->backup) { @rename($filename, sprintf('%s.bak', $filename)); } return $filename; }
[ "public", "function", "getFile", "(", "$", "filename", ")", "{", "$", "filename", "=", "$", "this", "->", "outDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ";", "$", "this", "->", "mkdir", "(", "dirname", "(", "$", "filename", ")", ")", ";", ...
Check file if already exist and do backup if necessary. @param string $filename The file name @return string
[ "Check", "file", "if", "already", "exist", "and", "do", "backup", "if", "necessary", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Storage/Storage.php#L111-L120
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Storage/Storage.php
Storage.hasFile
public function hasFile($filename) { return is_file($filename = $this->outDir.DIRECTORY_SEPARATOR.$filename) ? true : false; }
php
public function hasFile($filename) { return is_file($filename = $this->outDir.DIRECTORY_SEPARATOR.$filename) ? true : false; }
[ "public", "function", "hasFile", "(", "$", "filename", ")", "{", "return", "is_file", "(", "$", "filename", "=", "$", "this", "->", "outDir", ".", "DIRECTORY_SEPARATOR", ".", "$", "filename", ")", "?", "true", ":", "false", ";", "}" ]
Check file if already exist. @param string $filename The file name @return boolean
[ "Check", "file", "if", "already", "exist", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Storage/Storage.php#L128-L131
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Index.php
Index.getColumnNames
public function getColumnNames() { $columns = array(); foreach ($this->columns as $refColumn) { $columns[] = $refColumn->getColumnName(); } return $columns; }
php
public function getColumnNames() { $columns = array(); foreach ($this->columns as $refColumn) { $columns[] = $refColumn->getColumnName(); } return $columns; }
[ "public", "function", "getColumnNames", "(", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "columns", "as", "$", "refColumn", ")", "{", "$", "columns", "[", "]", "=", "$", "refColumn", "->", "getColumnName", ...
Get index column names. @return array
[ "Get", "index", "column", "names", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Index.php#L121-L129
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/View.php
View.getViewFileName
public function getViewFileName($format = null, $vars = array()) { if (0 === strlen($filename = $this->getDocument()->translateFilename($format, $this, $vars))) { $filename = implode('.', array($this->getSchema()->getName(), $this->getRawViewName(), $this->getFormatter()->getFileExtension())); } return $filename; }
php
public function getViewFileName($format = null, $vars = array()) { if (0 === strlen($filename = $this->getDocument()->translateFilename($format, $this, $vars))) { $filename = implode('.', array($this->getSchema()->getName(), $this->getRawViewName(), $this->getFormatter()->getFileExtension())); } return $filename; }
[ "public", "function", "getViewFileName", "(", "$", "format", "=", "null", ",", "$", "vars", "=", "array", "(", ")", ")", "{", "if", "(", "0", "===", "strlen", "(", "$", "filename", "=", "$", "this", "->", "getDocument", "(", ")", "->", "translateFile...
Get view file name. @param string $format The filename format @param array $vars The overriden variables @return string
[ "Get", "view", "file", "name", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/View.php#L141-L149
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Document.php
Document.load
public function load($filename) { $this->filename = $filename; $this->readXML($this->filename); $this->configure($this->xml->value); $this->loadUserDatatypes(); $this->parse(); }
php
public function load($filename) { $this->filename = $filename; $this->readXML($this->filename); $this->configure($this->xml->value); $this->loadUserDatatypes(); $this->parse(); }
[ "public", "function", "load", "(", "$", "filename", ")", "{", "$", "this", "->", "filename", "=", "$", "filename", ";", "$", "this", "->", "readXML", "(", "$", "this", "->", "filename", ")", ";", "$", "this", "->", "configure", "(", "$", "this", "-...
Load a workbench file. @param string $filename
[ "Load", "a", "workbench", "file", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Document.php#L195-L202
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Document.php
Document.translateFilename
public function translateFilename($format, Base $object, $vars = array(), $check = true) { if ($object && ($filename = $object->translateVars(null !== $format ? $format : $this->getConfig()->get(FormatterInterface::CFG_FILENAME), $vars))) { if ($check && false !== strpos($filename, '%')) { throw new \Exception(sprintf('All filename variable where not converted. Perhaps a misstyped name (%s) ?', substr($filename, strpos($filename, '%'), strrpos($filename, '%')))); } return $filename; } }
php
public function translateFilename($format, Base $object, $vars = array(), $check = true) { if ($object && ($filename = $object->translateVars(null !== $format ? $format : $this->getConfig()->get(FormatterInterface::CFG_FILENAME), $vars))) { if ($check && false !== strpos($filename, '%')) { throw new \Exception(sprintf('All filename variable where not converted. Perhaps a misstyped name (%s) ?', substr($filename, strpos($filename, '%'), strrpos($filename, '%')))); } return $filename; } }
[ "public", "function", "translateFilename", "(", "$", "format", ",", "Base", "$", "object", ",", "$", "vars", "=", "array", "(", ")", ",", "$", "check", "=", "true", ")", "{", "if", "(", "$", "object", "&&", "(", "$", "filename", "=", "$", "object",...
Translate and replace variable tags with contextual data from object using supplied format. If format omitted, it considered equal to configuration `FormatterInterface::CFG_FILENAME`. By default, the translated filename will be checked against the variables provided by the object to ensure no variables tag ('%var%') left. @param string $format Filename format @param \MwbExporter\Model\Base $object The object to translate @param array $vars The overriden variables @param bool $check True to check the translated filename @throws \Exception @return string
[ "Translate", "and", "replace", "variable", "tags", "with", "contextual", "data", "from", "object", "using", "supplied", "format", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Document.php#L278-L288
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Object/Base.php
Base.wrapLines
protected function wrapLines($lines, $indentationLevel = 0) { if ($wrapper = $this->getOption('wrapper')) { $lines = explode("\n", $lines); for ($i = 0; $i < count($lines); $i++) { // first line ignored if ($i === 0) { continue; } $line = $lines[$i]; if ($indentationLevel && $i < count($lines) - 1) { $line = str_repeat($this->getOption('indentation'), $indentationLevel) . $line; } $lines[$i] = sprintf($wrapper, $line); } $lines = implode("\n", $lines); } return $lines; }
php
protected function wrapLines($lines, $indentationLevel = 0) { if ($wrapper = $this->getOption('wrapper')) { $lines = explode("\n", $lines); for ($i = 0; $i < count($lines); $i++) { // first line ignored if ($i === 0) { continue; } $line = $lines[$i]; if ($indentationLevel && $i < count($lines) - 1) { $line = str_repeat($this->getOption('indentation'), $indentationLevel) . $line; } $lines[$i] = sprintf($wrapper, $line); } $lines = implode("\n", $lines); } return $lines; }
[ "protected", "function", "wrapLines", "(", "$", "lines", ",", "$", "indentationLevel", "=", "0", ")", "{", "if", "(", "$", "wrapper", "=", "$", "this", "->", "getOption", "(", "'wrapper'", ")", ")", "{", "$", "lines", "=", "explode", "(", "\"\\n\"", ...
Wrap text. @param string $lines The text @param int $indentationLevel @return string
[ "Wrap", "text", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Object/Base.php#L137-L156
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.initColumns
public function initColumns() { $elems = $this->node->xpath("value[@key='columns']"); $this->columns = $this->getFormatter()->createColumns($this, $elems[0]); return $this; }
php
public function initColumns() { $elems = $this->node->xpath("value[@key='columns']"); $this->columns = $this->getFormatter()->createColumns($this, $elems[0]); return $this; }
[ "public", "function", "initColumns", "(", ")", "{", "$", "elems", "=", "$", "this", "->", "node", "->", "xpath", "(", "\"value[@key='columns']\"", ")", ";", "$", "this", "->", "columns", "=", "$", "this", "->", "getFormatter", "(", ")", "->", "createColu...
Initialize table columns. @return \MwbExporter\Model\Table
[ "Initialize", "table", "columns", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L91-L97
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.initIndices
public function initIndices() { $elems = $this->node->xpath("value[@key='indices']"); $this->indices = $this->getFormatter()->createIndices($this, $elems[0]); return $this; }
php
public function initIndices() { $elems = $this->node->xpath("value[@key='indices']"); $this->indices = $this->getFormatter()->createIndices($this, $elems[0]); return $this; }
[ "public", "function", "initIndices", "(", ")", "{", "$", "elems", "=", "$", "this", "->", "node", "->", "xpath", "(", "\"value[@key='indices']\"", ")", ";", "$", "this", "->", "indices", "=", "$", "this", "->", "getFormatter", "(", ")", "->", "createIndi...
Initialize table indices. @return \MwbExporter\Model\Table
[ "Initialize", "table", "indices", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L104-L110
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.initForeignKeys
public function initForeignKeys() { $elems = $this->node->xpath("value[@key='foreignKeys']"); $this->foreignKeys = $this->getFormatter()->createForeignKeys($this, $elems[0]); return $this; }
php
public function initForeignKeys() { $elems = $this->node->xpath("value[@key='foreignKeys']"); $this->foreignKeys = $this->getFormatter()->createForeignKeys($this, $elems[0]); return $this; }
[ "public", "function", "initForeignKeys", "(", ")", "{", "$", "elems", "=", "$", "this", "->", "node", "->", "xpath", "(", "\"value[@key='foreignKeys']\"", ")", ";", "$", "this", "->", "foreignKeys", "=", "$", "this", "->", "getFormatter", "(", ")", "->", ...
Initialize table foreign keys. @return \MwbExporter\Model\Table
[ "Initialize", "table", "foreign", "keys", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L117-L123
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.initManyToManyRelations
public function initManyToManyRelations() { if ($this->isManyToMany()) { $fk1 = $this->foreignKeys[0]; $fk2 = $this->foreignKeys[1]; $this->injectManyToMany($fk1, $fk2); $this->injectManyToMany($fk2, $fk1); } return $this; }
php
public function initManyToManyRelations() { if ($this->isManyToMany()) { $fk1 = $this->foreignKeys[0]; $fk2 = $this->foreignKeys[1]; $this->injectManyToMany($fk1, $fk2); $this->injectManyToMany($fk2, $fk1); } return $this; }
[ "public", "function", "initManyToManyRelations", "(", ")", "{", "if", "(", "$", "this", "->", "isManyToMany", "(", ")", ")", "{", "$", "fk1", "=", "$", "this", "->", "foreignKeys", "[", "0", "]", ";", "$", "fk2", "=", "$", "this", "->", "foreignKeys"...
Initialize many to many relations. @return \MwbExporter\Model\Table
[ "Initialize", "many", "to", "many", "relations", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L130-L140
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.injectManyToMany
protected function injectManyToMany(ForeignKey $fk1, ForeignKey $fk2) { $fk1->getReferencedTable()->setManyToManyRelation(array('reference' => $fk1, 'refTable' => $fk2->getReferencedTable())); return $this; }
php
protected function injectManyToMany(ForeignKey $fk1, ForeignKey $fk2) { $fk1->getReferencedTable()->setManyToManyRelation(array('reference' => $fk1, 'refTable' => $fk2->getReferencedTable())); return $this; }
[ "protected", "function", "injectManyToMany", "(", "ForeignKey", "$", "fk1", ",", "ForeignKey", "$", "fk2", ")", "{", "$", "fk1", "->", "getReferencedTable", "(", ")", "->", "setManyToManyRelation", "(", "array", "(", "'reference'", "=>", "$", "fk1", ",", "'r...
Inject a many to many relation into referenced table. @param \MwbExporter\Model\ForeignKey $fk1 @param \MwbExporter\Model\ForeignKey $fk2 @return \MwbExporter\Model\Table
[ "Inject", "a", "many", "to", "many", "relation", "into", "referenced", "table", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L149-L154
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.isManyToMany
public function isManyToMany($deep = true) { if (null === $this->isM2M) { switch (true) { // user hinted that this is a m2m table or not case in_array($m2m = $this->parseComment('m2m'), array('true', 'false')): $this->isM2M = 'true' === $m2m ? true : false; $this->getDocument()->addLog(sprintf(' * %s: M2M from comment "%s"', $this->getRawTableName(), var_export($this->isM2M, true))); break; // contains 2 foreign keys case (2 !== count($fkeys = $this->getForeignKeys())): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, foreign keys not equal to 2', $this->getRawTableName())); break; // different foreign tables case ($fkeys[0]->getReferencedTable()->getId() === $fkeys[1]->getReferencedTable()->getId()): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, foreign table is same', $this->getRawTableName())); break; // foreign tables is not many to many case $deep && $fkeys[0]->getReferencedTable()->isManyToMany(false): case $deep && $fkeys[1]->getReferencedTable()->isManyToMany(false): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, foreign table is M2M', $this->getRawTableName())); break; // has more columns than id + 2 x key columnns, is not many to many case (count($this->getColumns()) >= 3): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, columns are 3 or more', $this->getRawTableName())); break; default: $this->isM2M = true; $this->getDocument()->addLog(sprintf(' * %s: is M2M', $this->getRawTableName())); break; } } return $this->isM2M; }
php
public function isManyToMany($deep = true) { if (null === $this->isM2M) { switch (true) { // user hinted that this is a m2m table or not case in_array($m2m = $this->parseComment('m2m'), array('true', 'false')): $this->isM2M = 'true' === $m2m ? true : false; $this->getDocument()->addLog(sprintf(' * %s: M2M from comment "%s"', $this->getRawTableName(), var_export($this->isM2M, true))); break; // contains 2 foreign keys case (2 !== count($fkeys = $this->getForeignKeys())): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, foreign keys not equal to 2', $this->getRawTableName())); break; // different foreign tables case ($fkeys[0]->getReferencedTable()->getId() === $fkeys[1]->getReferencedTable()->getId()): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, foreign table is same', $this->getRawTableName())); break; // foreign tables is not many to many case $deep && $fkeys[0]->getReferencedTable()->isManyToMany(false): case $deep && $fkeys[1]->getReferencedTable()->isManyToMany(false): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, foreign table is M2M', $this->getRawTableName())); break; // has more columns than id + 2 x key columnns, is not many to many case (count($this->getColumns()) >= 3): $this->isM2M = false; $this->getDocument()->addLog(sprintf(' * %s: M2M set to false, columns are 3 or more', $this->getRawTableName())); break; default: $this->isM2M = true; $this->getDocument()->addLog(sprintf(' * %s: is M2M', $this->getRawTableName())); break; } } return $this->isM2M; }
[ "public", "function", "isManyToMany", "(", "$", "deep", "=", "true", ")", "{", "if", "(", "null", "===", "$", "this", "->", "isM2M", ")", "{", "switch", "(", "true", ")", "{", "// user hinted that this is a m2m table or not", "case", "in_array", "(", "$", ...
Check if this table is a many to many table. @param bool $deep True to check many to many relation for referenced tables @return bool
[ "Check", "if", "this", "table", "is", "a", "many", "to", "many", "table", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L229-L272
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.setManyToManyRelation
public function setManyToManyRelation($rel) { $key = $rel['refTable']->getModelName(); $this->_m2mRelations[$key] = $rel; $this->getDocument()->addLog(sprintf('Applying N <=> N relation "%s" for "%s <=> %s"', $rel['refTable']->getParameters()->get('name'), $this->getModelName(), $key)); return $this; }
php
public function setManyToManyRelation($rel) { $key = $rel['refTable']->getModelName(); $this->_m2mRelations[$key] = $rel; $this->getDocument()->addLog(sprintf('Applying N <=> N relation "%s" for "%s <=> %s"', $rel['refTable']->getParameters()->get('name'), $this->getModelName(), $key)); return $this; }
[ "public", "function", "setManyToManyRelation", "(", "$", "rel", ")", "{", "$", "key", "=", "$", "rel", "[", "'refTable'", "]", "->", "getModelName", "(", ")", ";", "$", "this", "->", "_m2mRelations", "[", "$", "key", "]", "=", "$", "rel", ";", "$", ...
Add a many to many relation. @param array $rel The relation @return \MwbExporter\Model\Table
[ "Add", "a", "many", "to", "many", "relation", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L295-L302
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getModelName
public function getModelName() { $tableName = $this->getRawTableName(); // check if table name is plural --> convert to singular if ( !$this->getConfig()->get(FormatterInterface::CFG_SKIP_PLURAL) && ($tableName != ($singular = Inflector::singularize($tableName))) ) { $tableName = $singular; } return $this->beautify($tableName); }
php
public function getModelName() { $tableName = $this->getRawTableName(); // check if table name is plural --> convert to singular if ( !$this->getConfig()->get(FormatterInterface::CFG_SKIP_PLURAL) && ($tableName != ($singular = Inflector::singularize($tableName))) ) { $tableName = $singular; } return $this->beautify($tableName); }
[ "public", "function", "getModelName", "(", ")", "{", "$", "tableName", "=", "$", "this", "->", "getRawTableName", "(", ")", ";", "// check if table name is plural --> convert to singular", "if", "(", "!", "$", "this", "->", "getConfig", "(", ")", "->", "get", ...
Get the table model name. @return string
[ "Get", "the", "table", "model", "name", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L319-L332
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.injectIndex
public function injectIndex(Index $index) { foreach ($this->_indexes as $_index) { if ($_index->getId() === $index->getId()) { return; } } $this->_indexes[] = $index; }
php
public function injectIndex(Index $index) { foreach ($this->_indexes as $_index) { if ($_index->getId() === $index->getId()) { return; } } $this->_indexes[] = $index; }
[ "public", "function", "injectIndex", "(", "Index", "$", "index", ")", "{", "foreach", "(", "$", "this", "->", "_indexes", "as", "$", "_index", ")", "{", "if", "(", "$", "_index", "->", "getId", "(", ")", "===", "$", "index", "->", "getId", "(", ")"...
Inject index. @param \MwbExporter\Model\Index $index
[ "Inject", "index", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L349-L357
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.injectRelation
public function injectRelation(ForeignKey $foreignKey) { foreach ($this->_relations as $_relation) { if ($_relation->getId() === $foreignKey->getId()) { return; } } $this->_relations[] = $foreignKey; }
php
public function injectRelation(ForeignKey $foreignKey) { foreach ($this->_relations as $_relation) { if ($_relation->getId() === $foreignKey->getId()) { return; } } $this->_relations[] = $foreignKey; }
[ "public", "function", "injectRelation", "(", "ForeignKey", "$", "foreignKey", ")", "{", "foreach", "(", "$", "this", "->", "_relations", "as", "$", "_relation", ")", "{", "if", "(", "$", "_relation", "->", "getId", "(", ")", "===", "$", "foreignKey", "->...
Inject relation. @param \MwbExporter\Model\ForeignKey $foreignKey
[ "Inject", "relation", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L364-L372
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getTableFileName
public function getTableFileName($format = null, $vars = array()) { if (0 === strlen($filename = $this->getDocument()->translateFilename($format, $this, $vars))) { $filename = implode('.', array($this->getSchema()->getName(), $this->getRawTableName(), $this->getFormatter()->getFileExtension())); } return $filename; }
php
public function getTableFileName($format = null, $vars = array()) { if (0 === strlen($filename = $this->getDocument()->translateFilename($format, $this, $vars))) { $filename = implode('.', array($this->getSchema()->getName(), $this->getRawTableName(), $this->getFormatter()->getFileExtension())); } return $filename; }
[ "public", "function", "getTableFileName", "(", "$", "format", "=", "null", ",", "$", "vars", "=", "array", "(", ")", ")", "{", "if", "(", "0", "===", "strlen", "(", "$", "filename", "=", "$", "this", "->", "getDocument", "(", ")", "->", "translateFil...
Get table file name. @param string $format The filename format @param array $vars The overriden variables @return string
[ "Get", "table", "file", "name", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L439-L447
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getAllForeignKeys
public function getAllForeignKeys() { $columns = array(); foreach ($this->getColumns() as $column) { foreach ($column->getForeignKeys() as $foreignKey) { if (array_key_exists($foreignKey->getId(), $columns)) { continue; } $columns[$foreignKey->getId()] = $foreignKey; } } return $columns; }
php
public function getAllForeignKeys() { $columns = array(); foreach ($this->getColumns() as $column) { foreach ($column->getForeignKeys() as $foreignKey) { if (array_key_exists($foreignKey->getId(), $columns)) { continue; } $columns[$foreignKey->getId()] = $foreignKey; } } return $columns; }
[ "public", "function", "getAllForeignKeys", "(", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "foreach", "(", "$", "column", "->", "getForeignKeys", "(",...
Get all foreign keys references. @return array \MwbExporter\Model\ForeignKey
[ "Get", "all", "foreign", "keys", "references", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L454-L467
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getAllLocalForeignKeys
public function getAllLocalForeignKeys() { $columns = array(); foreach ($this->getColumns() as $column) { foreach ($column->getLocalForeignKeys() as $foreignKey) { if (array_key_exists($foreignKey->getId(), $columns)) { continue; } $columns[$foreignKey->getId()] = $foreignKey; } } return $columns; }
php
public function getAllLocalForeignKeys() { $columns = array(); foreach ($this->getColumns() as $column) { foreach ($column->getLocalForeignKeys() as $foreignKey) { if (array_key_exists($foreignKey->getId(), $columns)) { continue; } $columns[$foreignKey->getId()] = $foreignKey; } } return $columns; }
[ "public", "function", "getAllLocalForeignKeys", "(", ")", "{", "$", "columns", "=", "array", "(", ")", ";", "foreach", "(", "$", "this", "->", "getColumns", "(", ")", "as", "$", "column", ")", "{", "foreach", "(", "$", "column", "->", "getLocalForeignKey...
Get all local foreign keys references. @return array \MwbExporter\Model\ForeignKey
[ "Get", "all", "local", "foreign", "keys", "references", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L474-L487
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.isForeignKeyIgnored
public function isForeignKeyIgnored($foreignKey) { // do not create entities for many2many tables if ($this->getConfig()->get(FormatterInterface::CFG_SKIP_M2M_TABLES) && $foreignKey->getReferencedTable()->isManyToMany()) { return true; } return false; }
php
public function isForeignKeyIgnored($foreignKey) { // do not create entities for many2many tables if ($this->getConfig()->get(FormatterInterface::CFG_SKIP_M2M_TABLES) && $foreignKey->getReferencedTable()->isManyToMany()) { return true; } return false; }
[ "public", "function", "isForeignKeyIgnored", "(", "$", "foreignKey", ")", "{", "// do not create entities for many2many tables", "if", "(", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "FormatterInterface", "::", "CFG_SKIP_M2M_TABLES", ")", "&&", "$",...
Check if foreign key should be ignored. @param \MwbExporter\Model\ForeignKey @return boolean
[ "Check", "if", "foreign", "key", "should", "be", "ignored", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L495-L503
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.isLocalForeignKeyIgnored
public function isLocalForeignKeyIgnored($foreignKey) { // do not create entities for many2many tables if ($this->getConfig()->get(FormatterInterface::CFG_SKIP_M2M_TABLES) && $foreignKey->getOwningTable()->isManyToMany()) { return true; } // do not output mapping in foreign table when the unidirectional option is set if ($foreignKey->parseComment('unidirectional') === 'true') { return true; } return false; }
php
public function isLocalForeignKeyIgnored($foreignKey) { // do not create entities for many2many tables if ($this->getConfig()->get(FormatterInterface::CFG_SKIP_M2M_TABLES) && $foreignKey->getOwningTable()->isManyToMany()) { return true; } // do not output mapping in foreign table when the unidirectional option is set if ($foreignKey->parseComment('unidirectional') === 'true') { return true; } return false; }
[ "public", "function", "isLocalForeignKeyIgnored", "(", "$", "foreignKey", ")", "{", "// do not create entities for many2many tables", "if", "(", "$", "this", "->", "getConfig", "(", ")", "->", "get", "(", "FormatterInterface", "::", "CFG_SKIP_M2M_TABLES", ")", "&&", ...
Check if local foreign key should be ignored. @param \MwbExporter\Model\ForeignKey @return boolean
[ "Check", "if", "local", "foreign", "key", "should", "be", "ignored", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L511-L523
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getForeignKeyReferenceCount
protected function getForeignKeyReferenceCount($fkey, $max = null) { $count = 0; $tablename = $fkey->getReferencedTable()->getRawTableName(); $columns = array(); foreach ($this->getColumns() as $column) { foreach ($column->getForeignKeys() as $foreignKey) { // process only unique foreign key if (in_array($foreignKey->getId(), $columns)) { continue; } $columns[] = $foreignKey->getId(); if ($this->checkForeignKeyOwnerTableName($foreignKey, $tablename)) { $count++; } if ($max && $count == $max) { break; } } } return $count; }
php
protected function getForeignKeyReferenceCount($fkey, $max = null) { $count = 0; $tablename = $fkey->getReferencedTable()->getRawTableName(); $columns = array(); foreach ($this->getColumns() as $column) { foreach ($column->getForeignKeys() as $foreignKey) { // process only unique foreign key if (in_array($foreignKey->getId(), $columns)) { continue; } $columns[] = $foreignKey->getId(); if ($this->checkForeignKeyOwnerTableName($foreignKey, $tablename)) { $count++; } if ($max && $count == $max) { break; } } } return $count; }
[ "protected", "function", "getForeignKeyReferenceCount", "(", "$", "fkey", ",", "$", "max", "=", "null", ")", "{", "$", "count", "=", "0", ";", "$", "tablename", "=", "$", "fkey", "->", "getReferencedTable", "(", ")", "->", "getRawTableName", "(", ")", ";...
Get the foreign key reference count. @param \MwbExporter\Model\ForeignKey $fkey The foreign key @param int $max The maximum count @return int
[ "Get", "the", "foreign", "key", "reference", "count", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L532-L554
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getRelationReferenceCount
protected function getRelationReferenceCount($fkey, $max = null) { $count = 0; $tablename = $fkey->getReferencedTable()->getRawTableName(); foreach ($this->getTableM2MRelations() as $relation) { // $relation key => reference (ForeignKey), refTable (Table) if ($this->checkReferenceTableName($relation['refTable'], $tablename)) { $count++; } if ($max && $count == $max) { break; } } return $count; }
php
protected function getRelationReferenceCount($fkey, $max = null) { $count = 0; $tablename = $fkey->getReferencedTable()->getRawTableName(); foreach ($this->getTableM2MRelations() as $relation) { // $relation key => reference (ForeignKey), refTable (Table) if ($this->checkReferenceTableName($relation['refTable'], $tablename)) { $count++; } if ($max && $count == $max) { break; } } return $count; }
[ "protected", "function", "getRelationReferenceCount", "(", "$", "fkey", ",", "$", "max", "=", "null", ")", "{", "$", "count", "=", "0", ";", "$", "tablename", "=", "$", "fkey", "->", "getReferencedTable", "(", ")", "->", "getRawTableName", "(", ")", ";",...
Get the relation reference count. @param \MwbExporter\Model\ForeignKey $fkey The foreign key @param int $max The maximum count @return int
[ "Get", "the", "relation", "reference", "count", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L563-L578
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.isMultiReferences
public function isMultiReferences($reference) { $count = 0; if ($reference) { // check foreign keys $count += $this->getForeignKeyReferenceCount($reference); // check relations $count += $this->getRelationReferenceCount($reference); } return $count > 1 ? true : false; }
php
public function isMultiReferences($reference) { $count = 0; if ($reference) { // check foreign keys $count += $this->getForeignKeyReferenceCount($reference); // check relations $count += $this->getRelationReferenceCount($reference); } return $count > 1 ? true : false; }
[ "public", "function", "isMultiReferences", "(", "$", "reference", ")", "{", "$", "count", "=", "0", ";", "if", "(", "$", "reference", ")", "{", "// check foreign keys", "$", "count", "+=", "$", "this", "->", "getForeignKeyReferenceCount", "(", "$", "referenc...
Check if foreign table reference is referenced by more than one column. @param \MwbExporter\Model\ForeignKey $reference The foreign key to check @return bool
[ "Check", "if", "foreign", "table", "reference", "is", "referenced", "by", "more", "than", "one", "column", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L586-L597
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.checkForeignKeyOwnerTableName
protected function checkForeignKeyOwnerTableName($foreign, $tablename) { return $this->checkReferenceTableName($foreign ? $foreign->getReferencedTable() : null, $tablename); }
php
protected function checkForeignKeyOwnerTableName($foreign, $tablename) { return $this->checkReferenceTableName($foreign ? $foreign->getReferencedTable() : null, $tablename); }
[ "protected", "function", "checkForeignKeyOwnerTableName", "(", "$", "foreign", ",", "$", "tablename", ")", "{", "return", "$", "this", "->", "checkReferenceTableName", "(", "$", "foreign", "?", "$", "foreign", "->", "getReferencedTable", "(", ")", ":", "null", ...
Check if foreign key owner tablename matched. @param \MwbExporter\Model\ForeignKey $foreign The foreign key @param string $tablename The table name @return bool
[ "Check", "if", "foreign", "key", "owner", "tablename", "matched", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L606-L609
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.formatRelatedName
public function formatRelatedName($column, $code = true) { return $code ? sprintf('RelatedBy%s', $this->beautify($column)) : sprintf('related by `%s`', $column); }
php
public function formatRelatedName($column, $code = true) { return $code ? sprintf('RelatedBy%s', $this->beautify($column)) : sprintf('related by `%s`', $column); }
[ "public", "function", "formatRelatedName", "(", "$", "column", ",", "$", "code", "=", "true", ")", "{", "return", "$", "code", "?", "sprintf", "(", "'RelatedBy%s'", ",", "$", "this", "->", "beautify", "(", "$", "column", ")", ")", ":", "sprintf", "(", ...
Format column name as relation to foreign table. @param string $column The column name @param bool $code If true, use result as PHP code or false, use as comment @return string
[ "Format", "column", "name", "as", "relation", "to", "foreign", "table", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L630-L633
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getRelatedName
public function getRelatedName($reference, $code = true) { return $this->isMultiReferences($reference) ? $this->formatRelatedName($reference->getLocal()->getColumnName(), $code) : ''; }
php
public function getRelatedName($reference, $code = true) { return $this->isMultiReferences($reference) ? $this->formatRelatedName($reference->getLocal()->getColumnName(), $code) : ''; }
[ "public", "function", "getRelatedName", "(", "$", "reference", ",", "$", "code", "=", "true", ")", "{", "return", "$", "this", "->", "isMultiReferences", "(", "$", "reference", ")", "?", "$", "this", "->", "formatRelatedName", "(", "$", "reference", "->", ...
Get the related name for one-to-many relation. @param \MwbExporter\Model\ForeignKey $reference The foreign key @param bool $code If true, use result as PHP code or false, use as comment @return string
[ "Get", "the", "related", "name", "for", "one", "-", "to", "-", "many", "relation", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L642-L645
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.getManyToManyRelatedName
public function getManyToManyRelatedName($tablename, $column, $code = true) { // foreign tables count $count = $this->getColumns()->getManyToManyCount($tablename); // m2m foreign tables count foreach ($this->getTableM2MRelations() as $relation) { if ($relation['refTable']->getRawTableName() === $tablename) { $count++; } } return $count > 1 ? $this->formatRelatedName($column, $code) : ''; }
php
public function getManyToManyRelatedName($tablename, $column, $code = true) { // foreign tables count $count = $this->getColumns()->getManyToManyCount($tablename); // m2m foreign tables count foreach ($this->getTableM2MRelations() as $relation) { if ($relation['refTable']->getRawTableName() === $tablename) { $count++; } } return $count > 1 ? $this->formatRelatedName($column, $code) : ''; }
[ "public", "function", "getManyToManyRelatedName", "(", "$", "tablename", ",", "$", "column", ",", "$", "code", "=", "true", ")", "{", "// foreign tables count", "$", "count", "=", "$", "this", "->", "getColumns", "(", ")", "->", "getManyToManyCount", "(", "$...
Get the related name for many-to-many relation. @param string $tablename The foreign tablename @param string $column The foreign column name @param bool $code If true, use result as PHP code or false, use as comment @return string
[ "Get", "the", "related", "name", "for", "many", "-", "to", "-", "many", "relation", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L655-L667
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Table.php
Table.writeTable
public function writeTable(WriterInterface $writer) { if (!$this->isExternal()) { $this->getColumns()->write($writer); $this->getIndices()->write($writer); $this->getForeignKeys()->write($writer); return self::WRITE_OK; } return self::WRITE_EXTERNAL; }
php
public function writeTable(WriterInterface $writer) { if (!$this->isExternal()) { $this->getColumns()->write($writer); $this->getIndices()->write($writer); $this->getForeignKeys()->write($writer); return self::WRITE_OK; } return self::WRITE_EXTERNAL; }
[ "public", "function", "writeTable", "(", "WriterInterface", "$", "writer", ")", "{", "if", "(", "!", "$", "this", "->", "isExternal", "(", ")", ")", "{", "$", "this", "->", "getColumns", "(", ")", "->", "write", "(", "$", "writer", ")", ";", "$", "...
Write table entity as code. @param \MwbExporter\Writer\WriterInterface $writer @return string
[ "Write", "table", "entity", "as", "code", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Table.php#L713-L724
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Object/YAML.php
YAML.canBeInlined
protected function canBeInlined($value) { if (!is_array($value) || $this->isKeysNumeric($value)) { return false; } foreach ($value as $v) { if (is_array($v)) { return false; } } return true; }
php
protected function canBeInlined($value) { if (!is_array($value) || $this->isKeysNumeric($value)) { return false; } foreach ($value as $v) { if (is_array($v)) { return false; } } return true; }
[ "protected", "function", "canBeInlined", "(", "$", "value", ")", "{", "if", "(", "!", "is_array", "(", "$", "value", ")", "||", "$", "this", "->", "isKeysNumeric", "(", "$", "value", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", ...
Check if value can be writen as inline array using curly brace. @param array $value @return boolean
[ "Check", "if", "value", "can", "be", "writen", "as", "inline", "array", "using", "curly", "brace", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Object/YAML.php#L114-L126
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Object/YAML.php
YAML.isArrayValueArray
protected function isArrayValueArray($array) { if (!is_array($array)) { return false; } foreach ($array as $k => $v) { if (!is_array($v)) { return false; } } return true; }
php
protected function isArrayValueArray($array) { if (!is_array($array)) { return false; } foreach ($array as $k => $v) { if (!is_array($v)) { return false; } } return true; }
[ "protected", "function", "isArrayValueArray", "(", "$", "array", ")", "{", "if", "(", "!", "is_array", "(", "$", "array", ")", ")", "{", "return", "false", ";", "}", "foreach", "(", "$", "array", "as", "$", "k", "=>", "$", "v", ")", "{", "if", "(...
Check if all array values is an array. @param array $array @return boolean
[ "Check", "if", "all", "array", "values", "is", "an", "array", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Object/YAML.php#L134-L146
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Writer/Writer.php
Writer.getIndentation
protected function getIndentation() { if ($this->document) { if ($this->document->getConfig()->get(FormatterInterface::CFG_USE_TABS)) { $indentation = "\t"; } else { $indentation = str_repeat(' ', $this->document->getConfig()->get(FormatterInterface::CFG_INDENTATION)); } return str_repeat($indentation, $this->indentation); } }
php
protected function getIndentation() { if ($this->document) { if ($this->document->getConfig()->get(FormatterInterface::CFG_USE_TABS)) { $indentation = "\t"; } else { $indentation = str_repeat(' ', $this->document->getConfig()->get(FormatterInterface::CFG_INDENTATION)); } return str_repeat($indentation, $this->indentation); } }
[ "protected", "function", "getIndentation", "(", ")", "{", "if", "(", "$", "this", "->", "document", ")", "{", "if", "(", "$", "this", "->", "document", "->", "getConfig", "(", ")", "->", "get", "(", "FormatterInterface", "::", "CFG_USE_TABS", ")", ")", ...
Get line indentation. @return string
[ "Get", "line", "indentation", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Writer/Writer.php#L279-L290
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Object/Annotation.php
Annotation.asCode
public function asCode($value) { $topLevel = true; if (func_num_args() > 1 && false === func_get_arg(1)) { $topLevel = false; } $inlineList = false; if (func_num_args() > 2) { $inlineList = func_get_arg(2); } if ($value instanceof Annotation) { $value = (string) $value; } elseif (is_bool($value)) { $value = $value ? 'true' : 'false'; } elseif (is_string($value)) { $value = '"'.$value.'"'; } elseif (is_array($value)) { $tmp = array(); $useKey = !$this->isKeysNumeric($value); foreach ($value as $k => $v) { // skip null value if (null === $v) { continue; } $v = $this->asCode($v, false, true); if (false === $topLevel) { $k = sprintf('"%s"', $k); } $tmp[] = $useKey ? sprintf("%s%s%s", $k, ($inlineList ? ':' : '='), $v) : $v; } $multiline = $this->getOption('multiline') && count($value) > 1; $value = implode($multiline ? ",\n" : ', ', $tmp).($multiline ? "\n" : ''); if ($topLevel) { $value = sprintf('(%s)', $value); } else { $value = sprintf('{%s}', $value); } if ($multiline) { $value = $this->wrapLines($value, 1); } } return $value; }
php
public function asCode($value) { $topLevel = true; if (func_num_args() > 1 && false === func_get_arg(1)) { $topLevel = false; } $inlineList = false; if (func_num_args() > 2) { $inlineList = func_get_arg(2); } if ($value instanceof Annotation) { $value = (string) $value; } elseif (is_bool($value)) { $value = $value ? 'true' : 'false'; } elseif (is_string($value)) { $value = '"'.$value.'"'; } elseif (is_array($value)) { $tmp = array(); $useKey = !$this->isKeysNumeric($value); foreach ($value as $k => $v) { // skip null value if (null === $v) { continue; } $v = $this->asCode($v, false, true); if (false === $topLevel) { $k = sprintf('"%s"', $k); } $tmp[] = $useKey ? sprintf("%s%s%s", $k, ($inlineList ? ':' : '='), $v) : $v; } $multiline = $this->getOption('multiline') && count($value) > 1; $value = implode($multiline ? ",\n" : ', ', $tmp).($multiline ? "\n" : ''); if ($topLevel) { $value = sprintf('(%s)', $value); } else { $value = sprintf('{%s}', $value); } if ($multiline) { $value = $this->wrapLines($value, 1); } } return $value; }
[ "public", "function", "asCode", "(", "$", "value", ")", "{", "$", "topLevel", "=", "true", ";", "if", "(", "func_num_args", "(", ")", ">", "1", "&&", "false", "===", "func_get_arg", "(", "1", ")", ")", "{", "$", "topLevel", "=", "false", ";", "}", ...
Convert value as code equivalent. @param mixed $value The value @param bool $topLevel Is this method being called from top level @return string
[ "Convert", "value", "as", "code", "equivalent", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Object/Annotation.php#L61-L107
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.getFormatters
public function getFormatters() { if (null === static::$formatters) { static::$formatters = array(); $dirs = array(); // if we'are using Composer, include these formatters if ($composer = $this->getComposer()) { $vendorDir = realpath(__DIR__.'/../../../..'); if (is_readable($installed = $vendorDir.'/composer/installed.json')) { $packages = json_decode(file_get_contents($installed), true); foreach ($packages as $package) { if (isset($package['name']) && is_dir($dir = $vendorDir.DIRECTORY_SEPARATOR.$package['name'])) { /** * Check for extended package extra attribute to customize * formatter inclusion. * * An example to include formatter using class: * { * "extra" : { * "mysql-workbench-schema-exporter" : { * "formatters" : { * "my-simple" : "\\My\\Simple\\Formatter", * "my-simple2" : "\\My\\Simple2\\Formatter" * } * } * } * } * * An example include formatter using namespace: * { * "extra" : { * "mysql-workbench-schema-exporter" : { * "namespaces" : { * "lib/My/Exporter" : "\\Acme\\My\\Exporter", * } * } * } * } */ if (isset($package['extra']) && isset($package['extra']['mysql-workbench-schema-exporter'])) { if (is_array($options = $package['extra']['mysql-workbench-schema-exporter'])) { if (isset($options['formatters']) && is_array($options['formatters'])) { foreach ($options['formatters'] as $name => $class) { $this->registerFormatter($name, $class); } } if (isset($options['namespaces']) && is_array($options['namespaces'])) { foreach ($options['namespaces'] as $lib => $namespace) { $dirs[$dir.DIRECTORY_SEPARATOR.$lib] = $namespace; } } continue; } } $dirs[] = $dir; } } } } else { $dirs[] = realpath(__DIR__.'/../..'); } $this->scanFormatters($dirs); } return static::$formatters; }
php
public function getFormatters() { if (null === static::$formatters) { static::$formatters = array(); $dirs = array(); // if we'are using Composer, include these formatters if ($composer = $this->getComposer()) { $vendorDir = realpath(__DIR__.'/../../../..'); if (is_readable($installed = $vendorDir.'/composer/installed.json')) { $packages = json_decode(file_get_contents($installed), true); foreach ($packages as $package) { if (isset($package['name']) && is_dir($dir = $vendorDir.DIRECTORY_SEPARATOR.$package['name'])) { /** * Check for extended package extra attribute to customize * formatter inclusion. * * An example to include formatter using class: * { * "extra" : { * "mysql-workbench-schema-exporter" : { * "formatters" : { * "my-simple" : "\\My\\Simple\\Formatter", * "my-simple2" : "\\My\\Simple2\\Formatter" * } * } * } * } * * An example include formatter using namespace: * { * "extra" : { * "mysql-workbench-schema-exporter" : { * "namespaces" : { * "lib/My/Exporter" : "\\Acme\\My\\Exporter", * } * } * } * } */ if (isset($package['extra']) && isset($package['extra']['mysql-workbench-schema-exporter'])) { if (is_array($options = $package['extra']['mysql-workbench-schema-exporter'])) { if (isset($options['formatters']) && is_array($options['formatters'])) { foreach ($options['formatters'] as $name => $class) { $this->registerFormatter($name, $class); } } if (isset($options['namespaces']) && is_array($options['namespaces'])) { foreach ($options['namespaces'] as $lib => $namespace) { $dirs[$dir.DIRECTORY_SEPARATOR.$lib] = $namespace; } } continue; } } $dirs[] = $dir; } } } } else { $dirs[] = realpath(__DIR__.'/../..'); } $this->scanFormatters($dirs); } return static::$formatters; }
[ "public", "function", "getFormatters", "(", ")", "{", "if", "(", "null", "===", "static", "::", "$", "formatters", ")", "{", "static", "::", "$", "formatters", "=", "array", "(", ")", ";", "$", "dirs", "=", "array", "(", ")", ";", "// if we'are using C...
Get available formatters. @return array
[ "Get", "available", "formatters", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L49-L114
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.getFormatter
public function getFormatter($name) { $formatters = $this->getFormatters(); if (!array_key_exists($name, $formatters)) { list($module, $exporter) = explode('-', $name, 2); $class = sprintf('\\MwbExporter\\Formatter\\%s\\%s\\Formatter', ucfirst(strtolower($module)), ucfirst(strtolower($exporter))); if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Unknown formatter "%s".', $name)); } } else { $class = $formatters[$name]; } return new $class($name); }
php
public function getFormatter($name) { $formatters = $this->getFormatters(); if (!array_key_exists($name, $formatters)) { list($module, $exporter) = explode('-', $name, 2); $class = sprintf('\\MwbExporter\\Formatter\\%s\\%s\\Formatter', ucfirst(strtolower($module)), ucfirst(strtolower($exporter))); if (!class_exists($class)) { throw new \InvalidArgumentException(sprintf('Unknown formatter "%s".', $name)); } } else { $class = $formatters[$name]; } return new $class($name); }
[ "public", "function", "getFormatter", "(", "$", "name", ")", "{", "$", "formatters", "=", "$", "this", "->", "getFormatters", "(", ")", ";", "if", "(", "!", "array_key_exists", "(", "$", "name", ",", "$", "formatters", ")", ")", "{", "list", "(", "$"...
Get formatter. @param string $name The formatter name @return \MwbExporter\Formatter\FormatterInterface
[ "Get", "formatter", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L122-L136
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.getWriter
public function getWriter($name) { $class = sprintf('\\MwbExporter\\Writer\\%sWriter', ucfirst($name)); if (class_exists($class)) { $writter = new $class(); return $writter; } throw new \InvalidArgumentException(sprintf('Writer %s not found.', $class)); }
php
public function getWriter($name) { $class = sprintf('\\MwbExporter\\Writer\\%sWriter', ucfirst($name)); if (class_exists($class)) { $writter = new $class(); return $writter; } throw new \InvalidArgumentException(sprintf('Writer %s not found.', $class)); }
[ "public", "function", "getWriter", "(", "$", "name", ")", "{", "$", "class", "=", "sprintf", "(", "'\\\\MwbExporter\\\\Writer\\\\%sWriter'", ",", "ucfirst", "(", "$", "name", ")", ")", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", "$"...
Get writer. @param string $name The writer name @return \MwbExporter\Writer\WriterInterface
[ "Get", "writer", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L144-L154
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.getStorage
public function getStorage($name) { $class = sprintf('\\MwbExporter\\Storage\\%sStorage', ucfirst($name)); if (class_exists($class)) { $storage = new $class(); return $storage; } throw new \InvalidArgumentException(sprintf('Storage %s not found.', $class)); }
php
public function getStorage($name) { $class = sprintf('\\MwbExporter\\Storage\\%sStorage', ucfirst($name)); if (class_exists($class)) { $storage = new $class(); return $storage; } throw new \InvalidArgumentException(sprintf('Storage %s not found.', $class)); }
[ "public", "function", "getStorage", "(", "$", "name", ")", "{", "$", "class", "=", "sprintf", "(", "'\\\\MwbExporter\\\\Storage\\\\%sStorage'", ",", "ucfirst", "(", "$", "name", ")", ")", ";", "if", "(", "class_exists", "(", "$", "class", ")", ")", "{", ...
Get storage. @param string $name The storage name @return \MwbExporter\Storage\StorageInterface
[ "Get", "storage", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L162-L172
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.export
public function export(FormatterInterface $formatter, $filename, $outDir, $storage = 'file') { if (!is_readable($filename)) { throw new \InvalidArgumentException(sprintf('Document not found "%s".', $filename)); } if ($formatter && $storage = $this->getStorage($storage)) { if ($formatter->getRegistry()->config->get(FormatterInterface::CFG_USE_LOGGED_STORAGE)) { $storage = new LoggedStorage($storage); } $storage->setName(basename($filename, '.mwb')); $storage->setOutdir(realpath($outDir) ? realpath($outDir) : $outDir); $storage->setBackup($formatter->getRegistry()->config->get(FormatterInterface::CFG_BACKUP_FILE)); $writer = $this->getWriter($formatter->getPreferredWriter()); $writer->setStorage($storage); if ($eol = strtolower(trim($formatter->getRegistry()->config->get(FormatterInterface::CFG_EOL)))) { switch ($eol) { case FormatterInterface::EOL_WIN: $writer->getBuffer()->setEol("\r\n"); break; case FormatterInterface::EOL_UNIX: $writer->getBuffer()->setEol("\n"); break; } } $document = new Document($formatter); if (strlen($logFile = $formatter->getRegistry()->config->get(FormatterInterface::CFG_LOG_FILE))) { $logger = new LoggerFile(array('filename' => $logFile)); } elseif ($formatter->getRegistry()->config->get(FormatterInterface::CFG_LOG_TO_CONSOLE)) { $logger = new LoggerConsole(); } else { $logger = new Logger(); } $document->setLogger($logger); $document->load($filename); $document->write($writer); if ($e = $document->getError()) { throw $e; } return $document; } }
php
public function export(FormatterInterface $formatter, $filename, $outDir, $storage = 'file') { if (!is_readable($filename)) { throw new \InvalidArgumentException(sprintf('Document not found "%s".', $filename)); } if ($formatter && $storage = $this->getStorage($storage)) { if ($formatter->getRegistry()->config->get(FormatterInterface::CFG_USE_LOGGED_STORAGE)) { $storage = new LoggedStorage($storage); } $storage->setName(basename($filename, '.mwb')); $storage->setOutdir(realpath($outDir) ? realpath($outDir) : $outDir); $storage->setBackup($formatter->getRegistry()->config->get(FormatterInterface::CFG_BACKUP_FILE)); $writer = $this->getWriter($formatter->getPreferredWriter()); $writer->setStorage($storage); if ($eol = strtolower(trim($formatter->getRegistry()->config->get(FormatterInterface::CFG_EOL)))) { switch ($eol) { case FormatterInterface::EOL_WIN: $writer->getBuffer()->setEol("\r\n"); break; case FormatterInterface::EOL_UNIX: $writer->getBuffer()->setEol("\n"); break; } } $document = new Document($formatter); if (strlen($logFile = $formatter->getRegistry()->config->get(FormatterInterface::CFG_LOG_FILE))) { $logger = new LoggerFile(array('filename' => $logFile)); } elseif ($formatter->getRegistry()->config->get(FormatterInterface::CFG_LOG_TO_CONSOLE)) { $logger = new LoggerConsole(); } else { $logger = new Logger(); } $document->setLogger($logger); $document->load($filename); $document->write($writer); if ($e = $document->getError()) { throw $e; } return $document; } }
[ "public", "function", "export", "(", "FormatterInterface", "$", "formatter", ",", "$", "filename", ",", "$", "outDir", ",", "$", "storage", "=", "'file'", ")", "{", "if", "(", "!", "is_readable", "(", "$", "filename", ")", ")", "{", "throw", "new", "\\...
Load workbench schema and generate the code. @param \MwbExporter\Formatter\FormatterInterface $formatter @param string $filename @param string $outDir @param string $storage @return \MwbExporter\Model\Document
[ "Load", "workbench", "schema", "and", "generate", "the", "code", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L183-L225
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.registerFormatter
public function registerFormatter($name, $class) { $name = strtolower(is_array($name) ? implode('-', $name) : $name); if (array_key_exists($name, static::$formatters)) { throw new \RuntimeException(sprintf('Formatter %s already registered.', $class)); } static::$formatters[$name] = $class; return $this; }
php
public function registerFormatter($name, $class) { $name = strtolower(is_array($name) ? implode('-', $name) : $name); if (array_key_exists($name, static::$formatters)) { throw new \RuntimeException(sprintf('Formatter %s already registered.', $class)); } static::$formatters[$name] = $class; return $this; }
[ "public", "function", "registerFormatter", "(", "$", "name", ",", "$", "class", ")", "{", "$", "name", "=", "strtolower", "(", "is_array", "(", "$", "name", ")", "?", "implode", "(", "'-'", ",", "$", "name", ")", ":", "$", "name", ")", ";", "if", ...
Register schema exporter class. @param string $name @param string $class @return \MwbExporter\Bootstrap
[ "Register", "schema", "exporter", "class", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L234-L243
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.scanFormatters
protected function scanFormatters($dirs) { $dirs = is_array($dirs) ? $dirs : array($dirs); foreach ($dirs as $key => $dir) { $namespace = null; if (is_string($key)) { $namespace = $dir; $dir = $key; } if (is_dir($dir)) { $parts = array('*', '*', 'Formatter.php'); if (null == $namespace) { $parts = array_merge(array('*', 'MwbExporter', 'Formatter'), $parts); } $pattern = implode(DIRECTORY_SEPARATOR, array_merge(array($dir), $parts)); foreach (glob($pattern) as $filename) { $parts = explode(DIRECTORY_SEPARATOR, dirname(realpath($filename))); $exporter = array_pop($parts); $module = array_pop($parts); $class = sprintf('%s\\%s\\%s\\Formatter', $namespace ?: '\\MwbExporter\\Formatter', $module, $exporter); $this->registerFormatter(array($module, $exporter), $class); } } } return $this; }
php
protected function scanFormatters($dirs) { $dirs = is_array($dirs) ? $dirs : array($dirs); foreach ($dirs as $key => $dir) { $namespace = null; if (is_string($key)) { $namespace = $dir; $dir = $key; } if (is_dir($dir)) { $parts = array('*', '*', 'Formatter.php'); if (null == $namespace) { $parts = array_merge(array('*', 'MwbExporter', 'Formatter'), $parts); } $pattern = implode(DIRECTORY_SEPARATOR, array_merge(array($dir), $parts)); foreach (glob($pattern) as $filename) { $parts = explode(DIRECTORY_SEPARATOR, dirname(realpath($filename))); $exporter = array_pop($parts); $module = array_pop($parts); $class = sprintf('%s\\%s\\%s\\Formatter', $namespace ?: '\\MwbExporter\\Formatter', $module, $exporter); $this->registerFormatter(array($module, $exporter), $class); } } } return $this; }
[ "protected", "function", "scanFormatters", "(", "$", "dirs", ")", "{", "$", "dirs", "=", "is_array", "(", "$", "dirs", ")", "?", "$", "dirs", ":", "array", "(", "$", "dirs", ")", ";", "foreach", "(", "$", "dirs", "as", "$", "key", "=>", "$", "dir...
Scan directories for available formatters. Try to guess if schema formatter (or exporter) is present in the specified directory which is named according to convention: MwbExporter\Formatter\*\*\Formatter.php. @param array $dirs @return \MwbExporter\Bootstrap
[ "Scan", "directories", "for", "available", "formatters", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L254-L280
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Bootstrap.php
Bootstrap.getComposer
protected function getComposer() { if ($autoloaders = spl_autoload_functions()) { foreach ($autoloaders as $autoload) { if (is_array($autoload)) { $class = $autoload[0]; if ('Composer\Autoload\ClassLoader' == get_class($class)) { return $class; } } } } }
php
protected function getComposer() { if ($autoloaders = spl_autoload_functions()) { foreach ($autoloaders as $autoload) { if (is_array($autoload)) { $class = $autoload[0]; if ('Composer\Autoload\ClassLoader' == get_class($class)) { return $class; } } } } }
[ "protected", "function", "getComposer", "(", ")", "{", "if", "(", "$", "autoloaders", "=", "spl_autoload_functions", "(", ")", ")", "{", "foreach", "(", "$", "autoloaders", "as", "$", "autoload", ")", "{", "if", "(", "is_array", "(", "$", "autoload", ")"...
Get Composer autoloader instance. @return \Composer\Autoload\ClassLoader
[ "Get", "Composer", "autoloader", "instance", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Bootstrap.php#L287-L299
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Helper/Comment.php
Comment.wrap
public static function wrap($comment, $format, $width = 80) { $result = array(); $width = $width - self::getWidth($format); // collect lines $lines = array(); foreach (explode("\n", $comment) as $line) { foreach (explode("\n", wordwrap($line, $width, "\n")) as $sline) { $lines[] = $sline; } } // write lines $no = 0; $count = count($lines); foreach ($lines as $line) { $no++; self::getLine($no, $count, $format, $line, $result); } return $result; }
php
public static function wrap($comment, $format, $width = 80) { $result = array(); $width = $width - self::getWidth($format); // collect lines $lines = array(); foreach (explode("\n", $comment) as $line) { foreach (explode("\n", wordwrap($line, $width, "\n")) as $sline) { $lines[] = $sline; } } // write lines $no = 0; $count = count($lines); foreach ($lines as $line) { $no++; self::getLine($no, $count, $format, $line, $result); } return $result; }
[ "public", "static", "function", "wrap", "(", "$", "comment", ",", "$", "format", ",", "$", "width", "=", "80", ")", "{", "$", "result", "=", "array", "(", ")", ";", "$", "width", "=", "$", "width", "-", "self", "::", "getWidth", "(", "$", "format...
Wrap comment. @param string $comment Comment content @param array $format Comment wrapper format @param int $width The line width @return array
[ "Wrap", "comment", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Helper/Comment.php#L45-L65
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Helper/Comment.php
Comment.getLine
protected static function getLine($line, $count, $format, $content, &$result) { // make sure format is an array $format = explode('|', $format); // is first line if (count($format) >= 3 && 1 === $line) { $result[] = $format[0]; } // format line $result[] = rtrim(sprintf(count($format) >= 3 ? $format[1] : $format[0], $content)); // is last line if (count($format) >= 3 && $count === $line) { $result[] = $format[2]; } }
php
protected static function getLine($line, $count, $format, $content, &$result) { // make sure format is an array $format = explode('|', $format); // is first line if (count($format) >= 3 && 1 === $line) { $result[] = $format[0]; } // format line $result[] = rtrim(sprintf(count($format) >= 3 ? $format[1] : $format[0], $content)); // is last line if (count($format) >= 3 && $count === $line) { $result[] = $format[2]; } }
[ "protected", "static", "function", "getLine", "(", "$", "line", ",", "$", "count", ",", "$", "format", ",", "$", "content", ",", "&", "$", "result", ")", "{", "// make sure format is an array", "$", "format", "=", "explode", "(", "'|'", ",", "$", "format...
Get comment line. @param int $line Current line number, start from 1 @param int $count Total line number @param array $format Comment format @param string $content Line content @param array $result Result array
[ "Get", "comment", "line", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Helper/Comment.php#L76-L90
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/ForeignKey.php
ForeignKey.getLocalM2MRelatedName
public function getLocalM2MRelatedName($code = true) { return $this->getReferencedTable()->getManyToManyRelatedName($this->getReferencedTable()->getRawTableName(), implode('_', $this->getLocalColumns()), $code); }
php
public function getLocalM2MRelatedName($code = true) { return $this->getReferencedTable()->getManyToManyRelatedName($this->getReferencedTable()->getRawTableName(), implode('_', $this->getLocalColumns()), $code); }
[ "public", "function", "getLocalM2MRelatedName", "(", "$", "code", "=", "true", ")", "{", "return", "$", "this", "->", "getReferencedTable", "(", ")", "->", "getManyToManyRelatedName", "(", "$", "this", "->", "getReferencedTable", "(", ")", "->", "getRawTableName...
Get local related name. @param boolean $code @return string
[ "Get", "local", "related", "name", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/ForeignKey.php#L207-L210
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/ForeignKey.php
ForeignKey.getForeignM2MRelatedName
public function getForeignM2MRelatedName($code = true) { return $this->getReferencedTable()->getManyToManyRelatedName($this->getOwningTable()->getRawTableName(), implode('_', $this->getLocalColumns()), $code); }
php
public function getForeignM2MRelatedName($code = true) { return $this->getReferencedTable()->getManyToManyRelatedName($this->getOwningTable()->getRawTableName(), implode('_', $this->getLocalColumns()), $code); }
[ "public", "function", "getForeignM2MRelatedName", "(", "$", "code", "=", "true", ")", "{", "return", "$", "this", "->", "getReferencedTable", "(", ")", "->", "getManyToManyRelatedName", "(", "$", "this", "->", "getOwningTable", "(", ")", "->", "getRawTableName",...
Get foreign related name. @param boolean $code @return string
[ "Get", "foreign", "related", "name", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/ForeignKey.php#L218-L221
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Formatter/Formatter.php
Formatter.addConfigurations
protected function addConfigurations($configurations = array()) { foreach ($configurations as $key => $value) { $this->registry->config->set($key, $value); } return $this; }
php
protected function addConfigurations($configurations = array()) { foreach ($configurations as $key => $value) { $this->registry->config->set($key, $value); } return $this; }
[ "protected", "function", "addConfigurations", "(", "$", "configurations", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "configurations", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "this", "->", "registry", "->", "config", "->", "set",...
Add configurations data. @param array $configurations Configurations data @return \MwbExporter\Formatter\Formatter
[ "Add", "configurations", "data", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Formatter/Formatter.php#L110-L117
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Formatter/Formatter.php
Formatter.addValidators
protected function addValidators($validators = array()) { foreach ($validators as $key => $validator) { $this->registry->validator->set($key, $validator); } return $this; }
php
protected function addValidators($validators = array()) { foreach ($validators as $key => $validator) { $this->registry->validator->set($key, $validator); } return $this; }
[ "protected", "function", "addValidators", "(", "$", "validators", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "validators", "as", "$", "key", "=>", "$", "validator", ")", "{", "$", "this", "->", "registry", "->", "validator", "->", "set", "(...
Add configuration validators. @param array $validators Configuration validators @return \MwbExporter\Formatter\Formatter
[ "Add", "configuration", "validators", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Formatter/Formatter.php#L135-L142
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Formatter/Formatter.php
Formatter.setup
public function setup($configurations = array()) { foreach ($configurations as $key => $value) { if (!$this->registry->config->has($key)) { throw new \RuntimeException(sprintf('Unknown setup key %s.', $key)); } if ($this->registry->validator->has($key)) { $validator = $this->registry->validator->get($key); if (!$validator->isValid($value)) { if (count($choices = $validator->getChoices())) { throw new \RuntimeException(sprintf('Invalid value %s for %s, values are %s.', var_export($value, true), $key, implode(', ', $choices))); } else { throw new \RuntimeException(sprintf('Invalid value %s for %s.', var_export($value, true), $key)); } } } $this->registry->config->set($key, $value); } return $this; }
php
public function setup($configurations = array()) { foreach ($configurations as $key => $value) { if (!$this->registry->config->has($key)) { throw new \RuntimeException(sprintf('Unknown setup key %s.', $key)); } if ($this->registry->validator->has($key)) { $validator = $this->registry->validator->get($key); if (!$validator->isValid($value)) { if (count($choices = $validator->getChoices())) { throw new \RuntimeException(sprintf('Invalid value %s for %s, values are %s.', var_export($value, true), $key, implode(', ', $choices))); } else { throw new \RuntimeException(sprintf('Invalid value %s for %s.', var_export($value, true), $key)); } } } $this->registry->config->set($key, $value); } return $this; }
[ "public", "function", "setup", "(", "$", "configurations", "=", "array", "(", ")", ")", "{", "foreach", "(", "$", "configurations", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "!", "$", "this", "->", "registry", "->", "config", "->", ...
Setup formatter. @param array $configurations @throws \RuntimeException @return \MwbExporter\Formatter\Formatter
[ "Setup", "formatter", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Formatter/Formatter.php#L161-L181
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Formatter/Formatter.php
Formatter.setDatatypeConverter
protected function setDatatypeConverter(DatatypeConverterInterface $datatypeConverter) { if (null == $datatypeConverter) { throw new \RuntimeException('DatatypeConverter can\'t be null.'); } $this->datatypeConverter = $datatypeConverter; $this->datatypeConverter->setup(); return $this; }
php
protected function setDatatypeConverter(DatatypeConverterInterface $datatypeConverter) { if (null == $datatypeConverter) { throw new \RuntimeException('DatatypeConverter can\'t be null.'); } $this->datatypeConverter = $datatypeConverter; $this->datatypeConverter->setup(); return $this; }
[ "protected", "function", "setDatatypeConverter", "(", "DatatypeConverterInterface", "$", "datatypeConverter", ")", "{", "if", "(", "null", "==", "$", "datatypeConverter", ")", "{", "throw", "new", "\\", "RuntimeException", "(", "'DatatypeConverter can\\'t be null.'", ")...
Set data type converter. @param \MwbExporter\Formatter\DatatypeConverterInterface $datatypeConverter @return \MwbExporter\Formatter\Formatter
[ "Set", "data", "type", "converter", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Formatter/Formatter.php#L198-L207
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Formatter/Formatter.php
Formatter.getComment
public function getComment($format) { return implode("\n", Comment::wrap(strtr($this->getCommentFormat(), $this->getCommentVars()), $format)); }
php
public function getComment($format) { return implode("\n", Comment::wrap(strtr($this->getCommentFormat(), $this->getCommentVars()), $format)); }
[ "public", "function", "getComment", "(", "$", "format", ")", "{", "return", "implode", "(", "\"\\n\"", ",", "Comment", "::", "wrap", "(", "strtr", "(", "$", "this", "->", "getCommentFormat", "(", ")", ",", "$", "this", "->", "getCommentVars", "(", ")", ...
Get comment. @param string $format Comment wrapper format @return string
[ "Get", "comment", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Formatter/Formatter.php#L427-L430
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Helper/ZendURLFormatter.php
ZendURLFormatter.fromCamelCaseToDashConnection
public static function fromCamelCaseToDashConnection($string) { $return = preg_replace_callback('/([A-Z])/', function($matches){ return '-' . ucwords(strtolower($matches[1])); }, $string); if (substr($return, 0,1) === '-') { $return = substr($return, 1, strlen($return)); } return $return; }
php
public static function fromCamelCaseToDashConnection($string) { $return = preg_replace_callback('/([A-Z])/', function($matches){ return '-' . ucwords(strtolower($matches[1])); }, $string); if (substr($return, 0,1) === '-') { $return = substr($return, 1, strlen($return)); } return $return; }
[ "public", "static", "function", "fromCamelCaseToDashConnection", "(", "$", "string", ")", "{", "$", "return", "=", "preg_replace_callback", "(", "'/([A-Z])/'", ",", "function", "(", "$", "matches", ")", "{", "return", "'-'", ".", "ucwords", "(", "strtolower", ...
Format a CamelCase word into Camel-Case format. @param string $word
[ "Format", "a", "CamelCase", "word", "into", "Camel", "-", "Case", "format", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Helper/ZendURLFormatter.php#L37-L48
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Base.php
Base.populateParameters
protected function populateParameters() { $this->parameters->clear(); if ($this->hasParameters() && $this->node) { foreach ($this->node->value as $key => $node) { $attributes = $node->attributes(); switch ((string) $attributes['type']) { case 'list': $value = array(); foreach ($node->children() as $c) { $value[] = (string) $c; } break; case 'int': if (strlen($value = (string) $node[0])) { $value = (int) $value; } else { $value = null; } break; default: $value = (string) $node[0]; break; } $this->parameters->set((string) $attributes['key'], $value); } } }
php
protected function populateParameters() { $this->parameters->clear(); if ($this->hasParameters() && $this->node) { foreach ($this->node->value as $key => $node) { $attributes = $node->attributes(); switch ((string) $attributes['type']) { case 'list': $value = array(); foreach ($node->children() as $c) { $value[] = (string) $c; } break; case 'int': if (strlen($value = (string) $node[0])) { $value = (int) $value; } else { $value = null; } break; default: $value = (string) $node[0]; break; } $this->parameters->set((string) $attributes['key'], $value); } } }
[ "protected", "function", "populateParameters", "(", ")", "{", "$", "this", "->", "parameters", "->", "clear", "(", ")", ";", "if", "(", "$", "this", "->", "hasParameters", "(", ")", "&&", "$", "this", "->", "node", ")", "{", "foreach", "(", "$", "thi...
Populate parameters from XML node.
[ "Populate", "parameters", "from", "XML", "node", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Base.php#L101-L130
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Base.php
Base.getDocument
public function getDocument() { if (null === $this->document) { $parent = $this->parent; while (true) { if (!$parent) { break; } if ($parent->parent) { $parent = $parent->parent; } else { break; } } $this->document = $parent; } return $this->document; }
php
public function getDocument() { if (null === $this->document) { $parent = $this->parent; while (true) { if (!$parent) { break; } if ($parent->parent) { $parent = $parent->parent; } else { break; } } $this->document = $parent; } return $this->document; }
[ "public", "function", "getDocument", "(", ")", "{", "if", "(", "null", "===", "$", "this", "->", "document", ")", "{", "$", "parent", "=", "$", "this", "->", "parent", ";", "while", "(", "true", ")", "{", "if", "(", "!", "$", "parent", ")", "{", ...
Get the document owner. @return \MwbExporter\Model\Document
[ "Get", "the", "document", "owner", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Base.php#L207-L225
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Base.php
Base.parseComment
public function parseComment($needle_raw, $comment = null) { if ($comment === null) { $comment = $this->parameters->get('comment'); } $needle_quoted = preg_quote($needle_raw); $pattern = sprintf('@\{(%1$s):%2$s\}(.+)\{\/(%1$s):%2$s\}@si', $this->getFormatter()->getCommentTagPrefix(), $needle_quoted); if (preg_match($pattern, $comment, $matches) && isset($matches[2])) { return $matches[2]; } }
php
public function parseComment($needle_raw, $comment = null) { if ($comment === null) { $comment = $this->parameters->get('comment'); } $needle_quoted = preg_quote($needle_raw); $pattern = sprintf('@\{(%1$s):%2$s\}(.+)\{\/(%1$s):%2$s\}@si', $this->getFormatter()->getCommentTagPrefix(), $needle_quoted); if (preg_match($pattern, $comment, $matches) && isset($matches[2])) { return $matches[2]; } }
[ "public", "function", "parseComment", "(", "$", "needle_raw", ",", "$", "comment", "=", "null", ")", "{", "if", "(", "$", "comment", "===", "null", ")", "{", "$", "comment", "=", "$", "this", "->", "parameters", "->", "get", "(", "'comment'", ")", ";...
Filters given comment for embedded code by a given keyword @param string $needle_raw @param string $comment @return string
[ "Filters", "given", "comment", "for", "embedded", "code", "by", "a", "given", "keyword" ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Base.php#L274-L284
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Base.php
Base.translateVars
public function translateVars($text, $vars = array()) { return strtr($text, array_merge($this->getParentVars(), $this->getVars(), $vars)); }
php
public function translateVars($text, $vars = array()) { return strtr($text, array_merge($this->getParentVars(), $this->getVars(), $vars)); }
[ "public", "function", "translateVars", "(", "$", "text", ",", "$", "vars", "=", "array", "(", ")", ")", "{", "return", "strtr", "(", "$", "text", ",", "array_merge", "(", "$", "this", "->", "getParentVars", "(", ")", ",", "$", "this", "->", "getVars"...
Translate text with object contextual data. @param string $text The text to translate @param array $vars The overriden variables @return string
[ "Translate", "text", "with", "object", "contextual", "data", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Base.php#L334-L337
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Base.php
Base.getParentVars
protected function getParentVars() { $vars = array(); $p = $this->getParent(); while ($p) { $vars = array_merge($p->getVars(), $vars); $p = $p->getParent(); } return $vars; }
php
protected function getParentVars() { $vars = array(); $p = $this->getParent(); while ($p) { $vars = array_merge($p->getVars(), $vars); $p = $p->getParent(); } return $vars; }
[ "protected", "function", "getParentVars", "(", ")", "{", "$", "vars", "=", "array", "(", ")", ";", "$", "p", "=", "$", "this", "->", "getParent", "(", ")", ";", "while", "(", "$", "p", ")", "{", "$", "vars", "=", "array_merge", "(", "$", "p", "...
Get parent variables. @return array
[ "Get", "parent", "variables", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Base.php#L344-L354
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
example/diff/Model/User.php
User.addBureau
public function addBureau(Bureau $bureau) { $bureau->addUser($this); $this->bureaus[] = $bureau; return $this; }
php
public function addBureau(Bureau $bureau) { $bureau->addUser($this); $this->bureaus[] = $bureau; return $this; }
[ "public", "function", "addBureau", "(", "Bureau", "$", "bureau", ")", "{", "$", "bureau", "->", "addUser", "(", "$", "this", ")", ";", "$", "this", "->", "bureaus", "[", "]", "=", "$", "bureau", ";", "return", "$", "this", ";", "}" ]
Add Bureau entity to collection. @param \Test\Bureau $bureau @return \Test\User
[ "Add", "Bureau", "entity", "to", "collection", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/example/diff/Model/User.php#L124-L130
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Schema.php
Schema.writeSchema
public function writeSchema(WriterInterface $writer) { $this->getDocument()->addLog(sprintf('Processing schema %s:', $this->name)); $this->getDocument()->addLog('Processing tables:'); $this->getTables()->write($writer); $this->getDocument()->addLog('Processing views:'); $this->getViews()->write($writer); return $this; }
php
public function writeSchema(WriterInterface $writer) { $this->getDocument()->addLog(sprintf('Processing schema %s:', $this->name)); $this->getDocument()->addLog('Processing tables:'); $this->getTables()->write($writer); $this->getDocument()->addLog('Processing views:'); $this->getViews()->write($writer); return $this; }
[ "public", "function", "writeSchema", "(", "WriterInterface", "$", "writer", ")", "{", "$", "this", "->", "getDocument", "(", ")", "->", "addLog", "(", "sprintf", "(", "'Processing schema %s:'", ",", "$", "this", "->", "name", ")", ")", ";", "$", "this", ...
Write schema entity as code. @param \MwbExporter\Writer\WriterInterface $writer @return \MwbExporter\Model\Schema
[ "Write", "schema", "entity", "as", "code", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Schema.php#L107-L116
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Formatter/DatatypeConverter.php
DatatypeConverter.getDataType
public function getDataType($key) { // check for existing datatype, and raise an exception // if it doesn't exist. Usefull when new data type defined // in the new version of MySQL Workbench if (isset($this->dataTypes[$key])) { return $this->dataTypes[$key]; } elseif (isset($this->userDatatypes[$key])) { return $this->userDatatypes[$key]; } else { throw new \RuntimeException(sprintf('Unknown data type "%s".', $key)); } }
php
public function getDataType($key) { // check for existing datatype, and raise an exception // if it doesn't exist. Usefull when new data type defined // in the new version of MySQL Workbench if (isset($this->dataTypes[$key])) { return $this->dataTypes[$key]; } elseif (isset($this->userDatatypes[$key])) { return $this->userDatatypes[$key]; } else { throw new \RuntimeException(sprintf('Unknown data type "%s".', $key)); } }
[ "public", "function", "getDataType", "(", "$", "key", ")", "{", "// check for existing datatype, and raise an exception", "// if it doesn't exist. Usefull when new data type defined", "// in the new version of MySQL Workbench", "if", "(", "isset", "(", "$", "this", "->", "dataTyp...
Get data type mapping for associated key. @return string|null
[ "Get", "data", "type", "mapping", "for", "associated", "key", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Formatter/DatatypeConverter.php#L69-L81
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Column.php
Column.getColumnType
public function getColumnType() { if (!($type = $this->links->get('simpleType'))) { $type = $this->links->get('userType'); } return $type; }
php
public function getColumnType() { if (!($type = $this->links->get('simpleType'))) { $type = $this->links->get('userType'); } return $type; }
[ "public", "function", "getColumnType", "(", ")", "{", "if", "(", "!", "(", "$", "type", "=", "$", "this", "->", "links", "->", "get", "(", "'simpleType'", ")", ")", ")", "{", "$", "type", "=", "$", "this", "->", "links", "->", "get", "(", "'userT...
Get column type, either by its simpleType or userType. @return string
[ "Get", "column", "type", "either", "by", "its", "simpleType", "or", "userType", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Column.php#L122-L129
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Column.php
Column.isUnsigned
public function isUnsigned() { $flags = $this->parameters->get('flags'); if (is_array($flags)) { return array_key_exists('UNSIGNED', array_flip($flags)); } return false; }
php
public function isUnsigned() { $flags = $this->parameters->get('flags'); if (is_array($flags)) { return array_key_exists('UNSIGNED', array_flip($flags)); } return false; }
[ "public", "function", "isUnsigned", "(", ")", "{", "$", "flags", "=", "$", "this", "->", "parameters", "->", "get", "(", "'flags'", ")", ";", "if", "(", "is_array", "(", "$", "flags", ")", ")", "{", "return", "array_key_exists", "(", "'UNSIGNED'", ",",...
Is the field an unsigned value @return boolean
[ "Is", "the", "field", "an", "unsigned", "value" ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Column.php#L238-L245
train
mysql-workbench-schema-exporter/mysql-workbench-schema-exporter
lib/MwbExporter/Model/Column.php
Column.getDefaultValue
public function getDefaultValue() { if (1 != $this->parameters->get('defaultValueIsNull')) { $defaultValue = $this->parameters->get('defaultValue'); if (strlen($defaultValue) && 'NULL' != $defaultValue) { return trim($defaultValue, '\'"'); } } }
php
public function getDefaultValue() { if (1 != $this->parameters->get('defaultValueIsNull')) { $defaultValue = $this->parameters->get('defaultValue'); if (strlen($defaultValue) && 'NULL' != $defaultValue) { return trim($defaultValue, '\'"'); } } }
[ "public", "function", "getDefaultValue", "(", ")", "{", "if", "(", "1", "!=", "$", "this", "->", "parameters", "->", "get", "(", "'defaultValueIsNull'", ")", ")", "{", "$", "defaultValue", "=", "$", "this", "->", "parameters", "->", "get", "(", "'default...
Get column default value. @return string
[ "Get", "column", "default", "value", "." ]
4026975cc2be283c04ba2131bbefe04350d1981d
https://github.com/mysql-workbench-schema-exporter/mysql-workbench-schema-exporter/blob/4026975cc2be283c04ba2131bbefe04350d1981d/lib/MwbExporter/Model/Column.php#L252-L260
train
laravel-validation-rules/phone
src/Phone.php
Phone.isPhone
protected function isPhone($value) { return $this->isE123($value) || $this->isE164($value) || $this->isNANP($value) || $this->isDigits($value); }
php
protected function isPhone($value) { return $this->isE123($value) || $this->isE164($value) || $this->isNANP($value) || $this->isDigits($value); }
[ "protected", "function", "isPhone", "(", "$", "value", ")", "{", "return", "$", "this", "->", "isE123", "(", "$", "value", ")", "||", "$", "this", "->", "isE164", "(", "$", "value", ")", "||", "$", "this", "->", "isNANP", "(", "$", "value", ")", ...
Checks through all validation methods to verify it is in a phone number format of some type @param string $value The phone number to check @return boolean is it correct format?
[ "Checks", "through", "all", "validation", "methods", "to", "verify", "it", "is", "in", "a", "phone", "number", "format", "of", "some", "type" ]
786d7aaeaeb79fc5a423c678d8a094fe4a11678d
https://github.com/laravel-validation-rules/phone/blob/786d7aaeaeb79fc5a423c678d8a094fe4a11678d/src/Phone.php#L37-L40
train
laravel-validation-rules/phone
src/Phone.php
Phone.isDigits
protected function isDigits($value) { $conditions = []; $conditions[] = strlen($value) >= 10; $conditions[] = strlen($value) <= 16; $conditions[] = preg_match("/[^\d]/i", $value) === 0; return (bool) array_product($conditions); }
php
protected function isDigits($value) { $conditions = []; $conditions[] = strlen($value) >= 10; $conditions[] = strlen($value) <= 16; $conditions[] = preg_match("/[^\d]/i", $value) === 0; return (bool) array_product($conditions); }
[ "protected", "function", "isDigits", "(", "$", "value", ")", "{", "$", "conditions", "=", "[", "]", ";", "$", "conditions", "[", "]", "=", "strlen", "(", "$", "value", ")", ">=", "10", ";", "$", "conditions", "[", "]", "=", "strlen", "(", "$", "v...
Format example 5555555555, 15555555555 @param [type] $value [description] @return boolean [description]
[ "Format", "example", "5555555555", "15555555555" ]
786d7aaeaeb79fc5a423c678d8a094fe4a11678d
https://github.com/laravel-validation-rules/phone/blob/786d7aaeaeb79fc5a423c678d8a094fe4a11678d/src/Phone.php#L47-L54
train
laravel-validation-rules/phone
src/Phone.php
Phone.isE164
protected function isE164($value) { $conditions = []; $conditions[] = strpos($value, "+") === 0; $conditions[] = strlen($value) >= 9; $conditions[] = strlen($value) <= 16; $conditions[] = preg_match("/[^\d+]/i", $value) === 0; return (bool) array_product($conditions); }
php
protected function isE164($value) { $conditions = []; $conditions[] = strpos($value, "+") === 0; $conditions[] = strlen($value) >= 9; $conditions[] = strlen($value) <= 16; $conditions[] = preg_match("/[^\d+]/i", $value) === 0; return (bool) array_product($conditions); }
[ "protected", "function", "isE164", "(", "$", "value", ")", "{", "$", "conditions", "=", "[", "]", ";", "$", "conditions", "[", "]", "=", "strpos", "(", "$", "value", ",", "\"+\"", ")", "===", "0", ";", "$", "conditions", "[", "]", "=", "strlen", ...
Format example +15555555555 @param string $value The phone number to check @return boolean is it correct format?
[ "Format", "example", "+", "15555555555" ]
786d7aaeaeb79fc5a423c678d8a094fe4a11678d
https://github.com/laravel-validation-rules/phone/blob/786d7aaeaeb79fc5a423c678d8a094fe4a11678d/src/Phone.php#L71-L79
train
skyronic/crudkit
src/CrudKit/Pages/BasicDataPage.php
BasicDataPage.handle_get_colSpec
public function handle_get_colSpec () { $url = new UrlHelper (); $filters = $url->get("filters_json", "[]"); $params = array( 'filters_json' => $filters ); return array( 'type' => 'json', 'data' => array ( 'count' => $this->dataProvider->getRowCount($params), 'schema' => $this->dataProvider->getSchema(), 'columns' => $this->dataProvider->getSummaryColumns() ) ); }
php
public function handle_get_colSpec () { $url = new UrlHelper (); $filters = $url->get("filters_json", "[]"); $params = array( 'filters_json' => $filters ); return array( 'type' => 'json', 'data' => array ( 'count' => $this->dataProvider->getRowCount($params), 'schema' => $this->dataProvider->getSchema(), 'columns' => $this->dataProvider->getSummaryColumns() ) ); }
[ "public", "function", "handle_get_colSpec", "(", ")", "{", "$", "url", "=", "new", "UrlHelper", "(", ")", ";", "$", "filters", "=", "$", "url", "->", "get", "(", "\"filters_json\"", ",", "\"[]\"", ")", ";", "$", "params", "=", "array", "(", "'filters_j...
Get the column specification and send to the client @return array
[ "Get", "the", "column", "specification", "and", "send", "to", "the", "client" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/Pages/BasicDataPage.php#L37-L53
train
skyronic/crudkit
src/CrudKit/Pages/BaseSQLDataPage.php
BaseSQLDataPage.addColumn
public function addColumn ($column_name, $label, $options = array()) { $this->sqlProvider->addColumn($column_name, $column_name, $label, $options); return $this; }
php
public function addColumn ($column_name, $label, $options = array()) { $this->sqlProvider->addColumn($column_name, $column_name, $label, $options); return $this; }
[ "public", "function", "addColumn", "(", "$", "column_name", ",", "$", "label", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "sqlProvider", "->", "addColumn", "(", "$", "column_name", ",", "$", "column_name", ",", "$", "labe...
Add a column to edit @param string $column_name @param string $label @param array $options @return $this
[ "Add", "a", "column", "to", "edit" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/Pages/BaseSQLDataPage.php#L39-L42
train
skyronic/crudkit
src/CrudKit/Pages/BaseSQLDataPage.php
BaseSQLDataPage.addColumnWithId
public function addColumnWithId ($id, $column_name, $label, $options = array()) { $this->sqlProvider->addColumn($id, $column_name, $label, $options); return $this; }
php
public function addColumnWithId ($id, $column_name, $label, $options = array()) { $this->sqlProvider->addColumn($id, $column_name, $label, $options); return $this; }
[ "public", "function", "addColumnWithId", "(", "$", "id", ",", "$", "column_name", ",", "$", "label", ",", "$", "options", "=", "array", "(", ")", ")", "{", "$", "this", "->", "sqlProvider", "->", "addColumn", "(", "$", "id", ",", "$", "column_name", ...
Add a column to edit with a unique ID @param string $id @param string $column_name @param string $label @param array $options @return $this
[ "Add", "a", "column", "to", "edit", "with", "a", "unique", "ID" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/Pages/BaseSQLDataPage.php#L58-L61
train
skyronic/crudkit
src/CrudKit/Data/SQLDataProvider.php
SQLDataProvider.processColumns
protected function processColumns () { // Get a schema manager and get the list of columns $sm = $this->conn->getSchemaManager(); $columns = $sm->listTableColumns($this->tableName); $type_lookup = array(); /** * @var $col Column */ foreach($columns as $col) { $type_lookup[$col->getName()] = $col; } foreach($this->colDefs as $item) { $id = $item['id']; $category = $item['category']; $opts = $item['options']; /** * @var $target SQLColumn */ $target = null; switch($category) { case SQLColumn::CATEGORY_VALUE: $target = new ValueColumn($id, $category, $opts); break; // case "foreign": // $target = new ForeignColumn($id, $category, $opts); // break; case SQLColumn::CATEGORY_PRIMARY: $target = new PrimaryColumn($id, $category, $opts); break; case SQLColumn::CATEGORY_EXTERNAL: $target = new ExternalColumn ($id, $category, $opts); break; default: //TODO: Throw library-specific exceptions throw new \Exception("Unknown category for column $category"); } $target->doctrineColumnLookup($type_lookup); $target->init (); $this->columns[$id] = $target; } }
php
protected function processColumns () { // Get a schema manager and get the list of columns $sm = $this->conn->getSchemaManager(); $columns = $sm->listTableColumns($this->tableName); $type_lookup = array(); /** * @var $col Column */ foreach($columns as $col) { $type_lookup[$col->getName()] = $col; } foreach($this->colDefs as $item) { $id = $item['id']; $category = $item['category']; $opts = $item['options']; /** * @var $target SQLColumn */ $target = null; switch($category) { case SQLColumn::CATEGORY_VALUE: $target = new ValueColumn($id, $category, $opts); break; // case "foreign": // $target = new ForeignColumn($id, $category, $opts); // break; case SQLColumn::CATEGORY_PRIMARY: $target = new PrimaryColumn($id, $category, $opts); break; case SQLColumn::CATEGORY_EXTERNAL: $target = new ExternalColumn ($id, $category, $opts); break; default: //TODO: Throw library-specific exceptions throw new \Exception("Unknown category for column $category"); } $target->doctrineColumnLookup($type_lookup); $target->init (); $this->columns[$id] = $target; } }
[ "protected", "function", "processColumns", "(", ")", "{", "// Get a schema manager and get the list of columns", "$", "sm", "=", "$", "this", "->", "conn", "->", "getSchemaManager", "(", ")", ";", "$", "columns", "=", "$", "sm", "->", "listTableColumns", "(", "$...
Converts columns from raw objects to more powerful cool objects
[ "Converts", "columns", "from", "raw", "objects", "to", "more", "powerful", "cool", "objects" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/Data/SQLDataProvider.php#L144-L191
train
skyronic/crudkit
src/CrudKit/Data/SQLDataProvider.php
SQLDataProvider.queryColumns
protected function queryColumns ($queryType, $queryValues, $valueType, $keyValue = false, $ignoreNull = false) { $target_columns = array(); if($queryType === "col_list") { // The caller has already specified a list of columns $target_columns = $queryValues; } else { /** * @var $key * @var SQLColumn $col */ foreach($this->columns as $key => $col) { if($queryType === "category") { if(in_array($col->category, $queryValues)) { $target_columns []= $key; } } else if ($queryType === "all") { $target_columns []= $key; } } } $results = array(); foreach($target_columns as $colKey) { /** * @var $column SQLColumn */ $column = $this->columns[$colKey]; $resultItem = null; switch($valueType) { case "id": $resultItem = $colKey; break; case "expr": $resultItem = $column->getExpr(); break; case "exprAs": $resultItem = $column->getExprAs(); break; case "object": $resultItem = $column; break; case "schema": $resultItem = $column->getSchema(); break; case "summary": $resultItem = $column->getSummaryConfig(); break; default: //TODO: Throw library-specific exceptions throw new \Exception("Unknown value type $valueType"); } if(is_null($resultItem) && $ignoreNull) { continue; } if($keyValue) { $results[$colKey] = $resultItem; } else { $results []= $resultItem; } } return $results; }
php
protected function queryColumns ($queryType, $queryValues, $valueType, $keyValue = false, $ignoreNull = false) { $target_columns = array(); if($queryType === "col_list") { // The caller has already specified a list of columns $target_columns = $queryValues; } else { /** * @var $key * @var SQLColumn $col */ foreach($this->columns as $key => $col) { if($queryType === "category") { if(in_array($col->category, $queryValues)) { $target_columns []= $key; } } else if ($queryType === "all") { $target_columns []= $key; } } } $results = array(); foreach($target_columns as $colKey) { /** * @var $column SQLColumn */ $column = $this->columns[$colKey]; $resultItem = null; switch($valueType) { case "id": $resultItem = $colKey; break; case "expr": $resultItem = $column->getExpr(); break; case "exprAs": $resultItem = $column->getExprAs(); break; case "object": $resultItem = $column; break; case "schema": $resultItem = $column->getSchema(); break; case "summary": $resultItem = $column->getSummaryConfig(); break; default: //TODO: Throw library-specific exceptions throw new \Exception("Unknown value type $valueType"); } if(is_null($resultItem) && $ignoreNull) { continue; } if($keyValue) { $results[$colKey] = $resultItem; } else { $results []= $resultItem; } } return $results; }
[ "protected", "function", "queryColumns", "(", "$", "queryType", ",", "$", "queryValues", ",", "$", "valueType", ",", "$", "keyValue", "=", "false", ",", "$", "ignoreNull", "=", "false", ")", "{", "$", "target_columns", "=", "array", "(", ")", ";", "if", ...
Super cool and useful function to query columns and get a reduced subset @param $queryType @param $queryValues @param $valueType @param bool $keyValue @return array @throws \Exception
[ "Super", "cool", "and", "useful", "function", "to", "query", "columns", "and", "get", "a", "reduced", "subset" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/Data/SQLDataProvider.php#L216-L285
train
skyronic/crudkit
src/CrudKit/Data/ArrayDataProvider.php
ArrayDataProvider.getValidatorForField
protected function getValidatorForField($formKey) { $validator = null; if( isset($this->schema[$formKey]['options']['validator']) ) { $validator = $this->schema[$formKey]['options']['validator']; if(!is_callable($validator)) { $validator = null; } } return $validator; }
php
protected function getValidatorForField($formKey) { $validator = null; if( isset($this->schema[$formKey]['options']['validator']) ) { $validator = $this->schema[$formKey]['options']['validator']; if(!is_callable($validator)) { $validator = null; } } return $validator; }
[ "protected", "function", "getValidatorForField", "(", "$", "formKey", ")", "{", "$", "validator", "=", "null", ";", "if", "(", "isset", "(", "$", "this", "->", "schema", "[", "$", "formKey", "]", "[", "'options'", "]", "[", "'validator'", "]", ")", ")"...
Returns a callable validator for this field if it exists, and null otherwise @param string $formKey @return callable|null
[ "Returns", "a", "callable", "validator", "for", "this", "field", "if", "it", "exists", "and", "null", "otherwise" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/Data/ArrayDataProvider.php#L200-L210
train
skyronic/crudkit
src/CrudKit/Data/ArrayDataProvider.php
ArrayDataProvider.getRequiredFields
protected function getRequiredFields() { $required = []; foreach($this->schema as $field => $fieldSchema) { if(isset($fieldSchema['options']['required']) && $fieldSchema['options']['required']) { $required[] = $field; } } return $required; }
php
protected function getRequiredFields() { $required = []; foreach($this->schema as $field => $fieldSchema) { if(isset($fieldSchema['options']['required']) && $fieldSchema['options']['required']) { $required[] = $field; } } return $required; }
[ "protected", "function", "getRequiredFields", "(", ")", "{", "$", "required", "=", "[", "]", ";", "foreach", "(", "$", "this", "->", "schema", "as", "$", "field", "=>", "$", "fieldSchema", ")", "{", "if", "(", "isset", "(", "$", "fieldSchema", "[", "...
Returns an array of require field names @return string[]
[ "Returns", "an", "array", "of", "require", "field", "names" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/Data/ArrayDataProvider.php#L217-L226
train
skyronic/crudkit
src/CrudKit/CrudKitApp.php
CrudKitApp.renderToString
public function renderToString () { if(!isset($this->staticRoot)) { throw new \Exception("Please set static root using `setStaticRoot`"); } $controller = new MainController($this); return $controller->handle(); }
php
public function renderToString () { if(!isset($this->staticRoot)) { throw new \Exception("Please set static root using `setStaticRoot`"); } $controller = new MainController($this); return $controller->handle(); }
[ "public", "function", "renderToString", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "staticRoot", ")", ")", "{", "throw", "new", "\\", "Exception", "(", "\"Please set static root using `setStaticRoot`\"", ")", ";", "}", "$", "controller", ...
Render your CrudKit app and return it as a string
[ "Render", "your", "CrudKit", "app", "and", "return", "it", "as", "a", "string" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/CrudKitApp.php#L102-L109
train
skyronic/crudkit
src/CrudKit/CrudKitApp.php
CrudKitApp.render
public function render () { $content = $this->renderToString(); if ($this->redirect !== null) { header("Location: ".$this->redirect); session_write_close(); exit(); return; } // Headers are also calculated in render to string if($this->isJsonResponse()) { header("Content-type: application/json;"); } echo $content; exit (); }
php
public function render () { $content = $this->renderToString(); if ($this->redirect !== null) { header("Location: ".$this->redirect); session_write_close(); exit(); return; } // Headers are also calculated in render to string if($this->isJsonResponse()) { header("Content-type: application/json;"); } echo $content; exit (); }
[ "public", "function", "render", "(", ")", "{", "$", "content", "=", "$", "this", "->", "renderToString", "(", ")", ";", "if", "(", "$", "this", "->", "redirect", "!==", "null", ")", "{", "header", "(", "\"Location: \"", ".", "$", "this", "->", "redir...
Render your CrudKit app and output to HTML
[ "Render", "your", "CrudKit", "app", "and", "output", "to", "HTML" ]
17a2c7131e96fff7a2e2ce6082592f1c2f6d533b
https://github.com/skyronic/crudkit/blob/17a2c7131e96fff7a2e2ce6082592f1c2f6d533b/src/CrudKit/CrudKitApp.php#L126-L144
train
laravel/legacy-encrypter
src/McryptEncrypter.php
McryptEncrypter.padAndMcrypt
protected function padAndMcrypt($value, $iv) { $value = $this->addPadding(serialize($value)); return mcrypt_encrypt($this->cipher, $this->key, $value, MCRYPT_MODE_CBC, $iv); }
php
protected function padAndMcrypt($value, $iv) { $value = $this->addPadding(serialize($value)); return mcrypt_encrypt($this->cipher, $this->key, $value, MCRYPT_MODE_CBC, $iv); }
[ "protected", "function", "padAndMcrypt", "(", "$", "value", ",", "$", "iv", ")", "{", "$", "value", "=", "$", "this", "->", "addPadding", "(", "serialize", "(", "$", "value", ")", ")", ";", "return", "mcrypt_encrypt", "(", "$", "this", "->", "cipher", ...
Pad and use mcrypt on the given value and input vector. @param string $value @param string $iv @return string
[ "Pad", "and", "use", "mcrypt", "on", "the", "given", "value", "and", "input", "vector", "." ]
0e53ea5051588e4e5de8d36b02f2b26335d0d987
https://github.com/laravel/legacy-encrypter/blob/0e53ea5051588e4e5de8d36b02f2b26335d0d987/src/McryptEncrypter.php#L100-L105
train
laravel/legacy-encrypter
src/McryptEncrypter.php
McryptEncrypter.addPadding
protected function addPadding($value) { $pad = $this->block - (strlen($value) % $this->block); return $value.str_repeat(chr($pad), $pad); }
php
protected function addPadding($value) { $pad = $this->block - (strlen($value) % $this->block); return $value.str_repeat(chr($pad), $pad); }
[ "protected", "function", "addPadding", "(", "$", "value", ")", "{", "$", "pad", "=", "$", "this", "->", "block", "-", "(", "strlen", "(", "$", "value", ")", "%", "$", "this", "->", "block", ")", ";", "return", "$", "value", ".", "str_repeat", "(", ...
Add PKCS7 padding to a given value. @param string $value @return string
[ "Add", "PKCS7", "padding", "to", "a", "given", "value", "." ]
0e53ea5051588e4e5de8d36b02f2b26335d0d987
https://github.com/laravel/legacy-encrypter/blob/0e53ea5051588e4e5de8d36b02f2b26335d0d987/src/McryptEncrypter.php#L151-L156
train
laravel/legacy-encrypter
src/McryptEncrypter.php
McryptEncrypter.paddingIsValid
protected function paddingIsValid($pad, $value) { $beforePad = strlen($value) - $pad; return substr($value, $beforePad) == str_repeat(substr($value, -1), $pad); }
php
protected function paddingIsValid($pad, $value) { $beforePad = strlen($value) - $pad; return substr($value, $beforePad) == str_repeat(substr($value, -1), $pad); }
[ "protected", "function", "paddingIsValid", "(", "$", "pad", ",", "$", "value", ")", "{", "$", "beforePad", "=", "strlen", "(", "$", "value", ")", "-", "$", "pad", ";", "return", "substr", "(", "$", "value", ",", "$", "beforePad", ")", "==", "str_repe...
Determine if the given padding for a value is valid. @param string $pad @param string $value @return bool
[ "Determine", "if", "the", "given", "padding", "for", "a", "value", "is", "valid", "." ]
0e53ea5051588e4e5de8d36b02f2b26335d0d987
https://github.com/laravel/legacy-encrypter/blob/0e53ea5051588e4e5de8d36b02f2b26335d0d987/src/McryptEncrypter.php#L178-L183
train
TypiCMS/Pages
src/Observers/SortObserver.php
SortObserver.updating
public function updating(Page $model) { if ($model->isDirty('parent_id')) { foreach (locales() as $locale) { $model->setTranslation('uri', $locale, ''); } } }
php
public function updating(Page $model) { if ($model->isDirty('parent_id')) { foreach (locales() as $locale) { $model->setTranslation('uri', $locale, ''); } } }
[ "public", "function", "updating", "(", "Page", "$", "model", ")", "{", "if", "(", "$", "model", "->", "isDirty", "(", "'parent_id'", ")", ")", "{", "foreach", "(", "locales", "(", ")", "as", "$", "locale", ")", "{", "$", "model", "->", "setTranslatio...
On update, update children uris. @param Page $model @return null
[ "On", "update", "update", "children", "uris", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Observers/SortObserver.php#L16-L23
train
TypiCMS/Pages
src/Presenters/ModulePresenter.php
ModulePresenter.parentUri
public function parentUri($locale) { $parentUri = $this->entity->translate('uri', $locale) ?: '/'; $parentUri = explode('/', $parentUri); array_pop($parentUri); $parentUri = implode('/', $parentUri).'/'; return $parentUri; }
php
public function parentUri($locale) { $parentUri = $this->entity->translate('uri', $locale) ?: '/'; $parentUri = explode('/', $parentUri); array_pop($parentUri); $parentUri = implode('/', $parentUri).'/'; return $parentUri; }
[ "public", "function", "parentUri", "(", "$", "locale", ")", "{", "$", "parentUri", "=", "$", "this", "->", "entity", "->", "translate", "(", "'uri'", ",", "$", "locale", ")", "?", ":", "'/'", ";", "$", "parentUri", "=", "explode", "(", "'/'", ",", ...
Get Uri without last segment. @param string $locale @return string URI without last segment
[ "Get", "Uri", "without", "last", "segment", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Presenters/ModulePresenter.php#L16-L24
train
TypiCMS/Pages
src/Repositories/EloquentPage.php
EloquentPage.getFirstByUri
public function getFirstByUri($uri) { if (!request('preview')) { $this->where(column('status'), '1'); } return $this->findBy(column('uri'), $uri); }
php
public function getFirstByUri($uri) { if (!request('preview')) { $this->where(column('status'), '1'); } return $this->findBy(column('uri'), $uri); }
[ "public", "function", "getFirstByUri", "(", "$", "uri", ")", "{", "if", "(", "!", "request", "(", "'preview'", ")", ")", "{", "$", "this", "->", "where", "(", "column", "(", "'status'", ")", ",", "'1'", ")", ";", "}", "return", "$", "this", "->", ...
Get a page by its uri. @param string $uri @return TypiCMS\Modules\Models\Page
[ "Get", "a", "page", "by", "its", "uri", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Repositories/EloquentPage.php#L22-L29
train
TypiCMS/Pages
src/Repositories/EloquentPage.php
EloquentPage.getSubMenu
public function getSubMenu($uri, $all = false) { $rootUriArray = explode('/', $uri); $uri = $rootUriArray[0]; if (in_array($uri, locales())) { if (isset($rootUriArray[1])) { $uri .= '/'.$rootUriArray[1]; // add next part of uri in locale } } $repository = Pages::where(column('uri'), '!=', $uri); if (!$all) { $repository->where(column('status'), '1'); } $models = $repository->orderBy('position', 'asc') ->findWhere([column('uri'), 'LIKE', '\"'.$uri.'%']) ->noCleaning() ->nest(); return $models; }
php
public function getSubMenu($uri, $all = false) { $rootUriArray = explode('/', $uri); $uri = $rootUriArray[0]; if (in_array($uri, locales())) { if (isset($rootUriArray[1])) { $uri .= '/'.$rootUriArray[1]; // add next part of uri in locale } } $repository = Pages::where(column('uri'), '!=', $uri); if (!$all) { $repository->where(column('status'), '1'); } $models = $repository->orderBy('position', 'asc') ->findWhere([column('uri'), 'LIKE', '\"'.$uri.'%']) ->noCleaning() ->nest(); return $models; }
[ "public", "function", "getSubMenu", "(", "$", "uri", ",", "$", "all", "=", "false", ")", "{", "$", "rootUriArray", "=", "explode", "(", "'/'", ",", "$", "uri", ")", ";", "$", "uri", "=", "$", "rootUriArray", "[", "0", "]", ";", "if", "(", "in_arr...
Get submenu for a page. @return Collection
[ "Get", "submenu", "for", "a", "page", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Repositories/EloquentPage.php#L36-L58
train
TypiCMS/Pages
src/Models/Page.php
Page.uri
public function uri($locale = null) { $locale = $locale ?: config('app.locale'); $uri = $this->translate('uri', $locale); if ( config('app.fallback_locale') != $locale || config('typicms.main_locale_in_url') ) { $uri = $uri ? $locale.'/'.$uri : $locale; } return $uri ?: '/'; }
php
public function uri($locale = null) { $locale = $locale ?: config('app.locale'); $uri = $this->translate('uri', $locale); if ( config('app.fallback_locale') != $locale || config('typicms.main_locale_in_url') ) { $uri = $uri ? $locale.'/'.$uri : $locale; } return $uri ?: '/'; }
[ "public", "function", "uri", "(", "$", "locale", "=", "null", ")", "{", "$", "locale", "=", "$", "locale", "?", ":", "config", "(", "'app.locale'", ")", ";", "$", "uri", "=", "$", "this", "->", "translate", "(", "'uri'", ",", "$", "locale", ")", ...
Get front office uri. @param string $locale @return string
[ "Get", "front", "office", "uri", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Models/Page.php#L46-L58
train
TypiCMS/Pages
src/Events/ResetChildren.php
ResetChildren.resetChildrenUri
public function resetChildrenUri(Page $page) { foreach ($page->subpages as $subpage) { $uris = $subpage->getTranslations('uri'); foreach ($uris as $locale => $uri) { $subpage->forgetTranslation('uri', $locale); } $subpage->save(); $this->resetChildrenUri($subpage); } }
php
public function resetChildrenUri(Page $page) { foreach ($page->subpages as $subpage) { $uris = $subpage->getTranslations('uri'); foreach ($uris as $locale => $uri) { $subpage->forgetTranslation('uri', $locale); } $subpage->save(); $this->resetChildrenUri($subpage); } }
[ "public", "function", "resetChildrenUri", "(", "Page", "$", "page", ")", "{", "foreach", "(", "$", "page", "->", "subpages", "as", "$", "subpage", ")", "{", "$", "uris", "=", "$", "subpage", "->", "getTranslations", "(", "'uri'", ")", ";", "foreach", "...
Recursive method for emptying subpages URI UriObserver will rebuild URIs. @param Page $page @return null
[ "Recursive", "method", "for", "emptying", "subpages", "URI", "UriObserver", "will", "rebuild", "URIs", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Events/ResetChildren.php#L18-L28
train
TypiCMS/Pages
src/Http/Controllers/PublicController.php
PublicController.findPageByUri
private function findPageByUri($uri) { $repository = $this->repository->with('images', 'documents', 'publishedSections'); if ($uri === null) { return $repository->findBy('is_home', 1); } // Only locale in url if ( in_array($uri, locales()) && ( config('app.fallback_locale') != $uri || config('typicms.main_locale_in_url') ) ) { return $repository->findBy('is_home', 1); } return $repository->getFirstByUri($uri); }
php
private function findPageByUri($uri) { $repository = $this->repository->with('images', 'documents', 'publishedSections'); if ($uri === null) { return $repository->findBy('is_home', 1); } // Only locale in url if ( in_array($uri, locales()) && ( config('app.fallback_locale') != $uri || config('typicms.main_locale_in_url') ) ) { return $repository->findBy('is_home', 1); } return $repository->getFirstByUri($uri); }
[ "private", "function", "findPageByUri", "(", "$", "uri", ")", "{", "$", "repository", "=", "$", "this", "->", "repository", "->", "with", "(", "'images'", ",", "'documents'", ",", "'publishedSections'", ")", ";", "if", "(", "$", "uri", "===", "null", ")"...
Find page by URI. @return TypiCMS\Modules\Pages\Models\Page
[ "Find", "page", "by", "URI", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Http/Controllers/PublicController.php#L57-L77
train
TypiCMS/Pages
src/Http/Controllers/PublicController.php
PublicController.redirectToHomepage
public function redirectToHomepage() { $homepage = $this->repository->findBy('is_home', 1); $locale = $this->getBrowserLanguageOrDefault(); return redirect($homepage->uri($locale)); }
php
public function redirectToHomepage() { $homepage = $this->repository->findBy('is_home', 1); $locale = $this->getBrowserLanguageOrDefault(); return redirect($homepage->uri($locale)); }
[ "public", "function", "redirectToHomepage", "(", ")", "{", "$", "homepage", "=", "$", "this", "->", "repository", "->", "findBy", "(", "'is_home'", ",", "1", ")", ";", "$", "locale", "=", "$", "this", "->", "getBrowserLanguageOrDefault", "(", ")", ";", "...
Get browser language or default locale and redirect to homepage. @return \Illuminate\Http\RedirectResponse
[ "Get", "browser", "language", "or", "default", "locale", "and", "redirect", "to", "homepage", "." ]
b21f0f24a59184763a7b99b8c981d62b3864dfa6
https://github.com/TypiCMS/Pages/blob/b21f0f24a59184763a7b99b8c981d62b3864dfa6/src/Http/Controllers/PublicController.php#L84-L90
train