repository_name
stringlengths
5
67
func_path_in_repository
stringlengths
4
234
func_name
stringlengths
0
314
whole_func_string
stringlengths
52
3.87M
language
stringclasses
6 values
func_code_string
stringlengths
52
3.87M
func_code_tokens
listlengths
15
672k
func_documentation_string
stringlengths
1
47.2k
func_documentation_tokens
listlengths
1
3.92k
split_name
stringclasses
1 value
func_code_url
stringlengths
85
339
geocoder-php/google-maps-provider
GoogleMaps.php
GoogleMaps.buildQuery
private function buildQuery(string $url, string $locale = null, string $region = null): string { if (null !== $locale) { $url = sprintf('%s&language=%s', $url, $locale); } if (null !== $region) { $url = sprintf('%s&region=%s', $url, $region); } if (null !== $this->apiKey) { $url = sprintf('%s&key=%s', $url, $this->apiKey); } if (null !== $this->clientId) { $url = sprintf('%s&client=%s', $url, $this->clientId); if (null !== $this->channel) { $url = sprintf('%s&channel=%s', $url, $this->channel); } if (null !== $this->privateKey) { $url = $this->signQuery($url); } } return $url; }
php
private function buildQuery(string $url, string $locale = null, string $region = null): string { if (null !== $locale) { $url = sprintf('%s&language=%s', $url, $locale); } if (null !== $region) { $url = sprintf('%s&region=%s', $url, $region); } if (null !== $this->apiKey) { $url = sprintf('%s&key=%s', $url, $this->apiKey); } if (null !== $this->clientId) { $url = sprintf('%s&client=%s', $url, $this->clientId); if (null !== $this->channel) { $url = sprintf('%s&channel=%s', $url, $this->channel); } if (null !== $this->privateKey) { $url = $this->signQuery($url); } } return $url; }
[ "private", "function", "buildQuery", "(", "string", "$", "url", ",", "string", "$", "locale", "=", "null", ",", "string", "$", "region", "=", "null", ")", ":", "string", "{", "if", "(", "null", "!==", "$", "locale", ")", "{", "$", "url", "=", "spri...
@param string $url @param string $locale @return string query with extra params
[ "@param", "string", "$url", "@param", "string", "$locale" ]
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/GoogleMaps.php#L156-L183
geocoder-php/google-maps-provider
GoogleMaps.php
GoogleMaps.fetchUrl
private function fetchUrl(string $url, string $locale = null, int $limit, string $region = null): AddressCollection { $url = $this->buildQuery($url, $locale, $region); $content = $this->getUrlContents($url); $json = $this->validateResponse($url, $content); // no result if (!isset($json->results) || !count($json->results) || 'OK' !== $json->status) { return new AddressCollection([]); } $results = []; foreach ($json->results as $result) { $builder = new AddressBuilder($this->getName()); $this->parseCoordinates($builder, $result); // set official Google place id if (isset($result->place_id)) { $builder->setValue('id', $result->place_id); } // update address components foreach ($result->address_components as $component) { foreach ($component->types as $type) { $this->updateAddressComponent($builder, $type, $component); } } /** @var GoogleAddress $address */ $address = $builder->build(GoogleAddress::class); $address = $address->withId($builder->getValue('id')); if (isset($result->geometry->location_type)) { $address = $address->withLocationType($result->geometry->location_type); } if (isset($result->types)) { $address = $address->withResultType($result->types); } if (isset($result->formatted_address)) { $address = $address->withFormattedAddress($result->formatted_address); } $address = $address->withStreetAddress($builder->getValue('street_address')); $address = $address->withIntersection($builder->getValue('intersection')); $address = $address->withPolitical($builder->getValue('political')); $address = $address->withColloquialArea($builder->getValue('colloquial_area')); $address = $address->withWard($builder->getValue('ward')); $address = $address->withNeighborhood($builder->getValue('neighborhood')); $address = $address->withPremise($builder->getValue('premise')); $address = $address->withSubpremise($builder->getValue('subpremise')); $address = $address->withNaturalFeature($builder->getValue('natural_feature')); $address = $address->withAirport($builder->getValue('airport')); $address = $address->withPark($builder->getValue('park')); $address = $address->withPointOfInterest($builder->getValue('point_of_interest')); $address = $address->withEstablishment($builder->getValue('establishment')); $address = $address->withSubLocalityLevels($builder->getValue('subLocalityLevel', [])); $address = $address->withPartialMatch($result->partial_match ?? false); $results[] = $address; if (count($results) >= $limit) { break; } } return new AddressCollection($results); }
php
private function fetchUrl(string $url, string $locale = null, int $limit, string $region = null): AddressCollection { $url = $this->buildQuery($url, $locale, $region); $content = $this->getUrlContents($url); $json = $this->validateResponse($url, $content); // no result if (!isset($json->results) || !count($json->results) || 'OK' !== $json->status) { return new AddressCollection([]); } $results = []; foreach ($json->results as $result) { $builder = new AddressBuilder($this->getName()); $this->parseCoordinates($builder, $result); // set official Google place id if (isset($result->place_id)) { $builder->setValue('id', $result->place_id); } // update address components foreach ($result->address_components as $component) { foreach ($component->types as $type) { $this->updateAddressComponent($builder, $type, $component); } } /** @var GoogleAddress $address */ $address = $builder->build(GoogleAddress::class); $address = $address->withId($builder->getValue('id')); if (isset($result->geometry->location_type)) { $address = $address->withLocationType($result->geometry->location_type); } if (isset($result->types)) { $address = $address->withResultType($result->types); } if (isset($result->formatted_address)) { $address = $address->withFormattedAddress($result->formatted_address); } $address = $address->withStreetAddress($builder->getValue('street_address')); $address = $address->withIntersection($builder->getValue('intersection')); $address = $address->withPolitical($builder->getValue('political')); $address = $address->withColloquialArea($builder->getValue('colloquial_area')); $address = $address->withWard($builder->getValue('ward')); $address = $address->withNeighborhood($builder->getValue('neighborhood')); $address = $address->withPremise($builder->getValue('premise')); $address = $address->withSubpremise($builder->getValue('subpremise')); $address = $address->withNaturalFeature($builder->getValue('natural_feature')); $address = $address->withAirport($builder->getValue('airport')); $address = $address->withPark($builder->getValue('park')); $address = $address->withPointOfInterest($builder->getValue('point_of_interest')); $address = $address->withEstablishment($builder->getValue('establishment')); $address = $address->withSubLocalityLevels($builder->getValue('subLocalityLevel', [])); $address = $address->withPartialMatch($result->partial_match ?? false); $results[] = $address; if (count($results) >= $limit) { break; } } return new AddressCollection($results); }
[ "private", "function", "fetchUrl", "(", "string", "$", "url", ",", "string", "$", "locale", "=", "null", ",", "int", "$", "limit", ",", "string", "$", "region", "=", "null", ")", ":", "AddressCollection", "{", "$", "url", "=", "$", "this", "->", "bui...
@param string $url @param string $locale @param int $limit @param string $region @return AddressCollection @throws InvalidServerResponse @throws InvalidCredentials
[ "@param", "string", "$url", "@param", "string", "$locale", "@param", "int", "$limit", "@param", "string", "$region" ]
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/GoogleMaps.php#L196-L259
geocoder-php/google-maps-provider
GoogleMaps.php
GoogleMaps.updateAddressComponent
private function updateAddressComponent(AddressBuilder $builder, string $type, $values) { switch ($type) { case 'postal_code': $builder->setPostalCode($values->long_name); break; case 'locality': case 'postal_town': $builder->setLocality($values->long_name); break; case 'administrative_area_level_1': case 'administrative_area_level_2': case 'administrative_area_level_3': case 'administrative_area_level_4': case 'administrative_area_level_5': $builder->addAdminLevel(intval(substr($type, -1)), $values->long_name, $values->short_name); break; case 'sublocality_level_1': case 'sublocality_level_2': case 'sublocality_level_3': case 'sublocality_level_4': case 'sublocality_level_5': $subLocalityLevel = $builder->getValue('subLocalityLevel', []); $subLocalityLevel[] = [ 'level' => intval(substr($type, -1)), 'name' => $values->long_name, 'code' => $values->short_name, ]; $builder->setValue('subLocalityLevel', $subLocalityLevel); break; case 'country': $builder->setCountry($values->long_name); $builder->setCountryCode($values->short_name); break; case 'street_number': $builder->setStreetNumber($values->long_name); break; case 'route': $builder->setStreetName($values->long_name); break; case 'sublocality': $builder->setSubLocality($values->long_name); break; case 'street_address': case 'intersection': case 'political': case 'colloquial_area': case 'ward': case 'neighborhood': case 'premise': case 'subpremise': case 'natural_feature': case 'airport': case 'park': case 'point_of_interest': case 'establishment': $builder->setValue($type, $values->long_name); break; default: } }
php
private function updateAddressComponent(AddressBuilder $builder, string $type, $values) { switch ($type) { case 'postal_code': $builder->setPostalCode($values->long_name); break; case 'locality': case 'postal_town': $builder->setLocality($values->long_name); break; case 'administrative_area_level_1': case 'administrative_area_level_2': case 'administrative_area_level_3': case 'administrative_area_level_4': case 'administrative_area_level_5': $builder->addAdminLevel(intval(substr($type, -1)), $values->long_name, $values->short_name); break; case 'sublocality_level_1': case 'sublocality_level_2': case 'sublocality_level_3': case 'sublocality_level_4': case 'sublocality_level_5': $subLocalityLevel = $builder->getValue('subLocalityLevel', []); $subLocalityLevel[] = [ 'level' => intval(substr($type, -1)), 'name' => $values->long_name, 'code' => $values->short_name, ]; $builder->setValue('subLocalityLevel', $subLocalityLevel); break; case 'country': $builder->setCountry($values->long_name); $builder->setCountryCode($values->short_name); break; case 'street_number': $builder->setStreetNumber($values->long_name); break; case 'route': $builder->setStreetName($values->long_name); break; case 'sublocality': $builder->setSubLocality($values->long_name); break; case 'street_address': case 'intersection': case 'political': case 'colloquial_area': case 'ward': case 'neighborhood': case 'premise': case 'subpremise': case 'natural_feature': case 'airport': case 'park': case 'point_of_interest': case 'establishment': $builder->setValue($type, $values->long_name); break; default: } }
[ "private", "function", "updateAddressComponent", "(", "AddressBuilder", "$", "builder", ",", "string", "$", "type", ",", "$", "values", ")", "{", "switch", "(", "$", "type", ")", "{", "case", "'postal_code'", ":", "$", "builder", "->", "setPostalCode", "(", ...
Update current resultSet with given key/value. @param AddressBuilder $builder @param string $type Component type @param object $values The component values
[ "Update", "current", "resultSet", "with", "given", "key", "/", "value", "." ]
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/GoogleMaps.php#L268-L346
geocoder-php/google-maps-provider
GoogleMaps.php
GoogleMaps.signQuery
private function signQuery(string $query): string { $url = parse_url($query); $urlPartToSign = $url['path'].'?'.$url['query']; // Decode the private key into its binary format $decodedKey = base64_decode(str_replace(['-', '_'], ['+', '/'], $this->privateKey)); // Create a signature using the private key and the URL-encoded // string using HMAC SHA1. This signature will be binary. $signature = hash_hmac('sha1', $urlPartToSign, $decodedKey, true); $encodedSignature = str_replace(['+', '/'], ['-', '_'], base64_encode($signature)); return sprintf('%s&signature=%s', $query, $encodedSignature); }
php
private function signQuery(string $query): string { $url = parse_url($query); $urlPartToSign = $url['path'].'?'.$url['query']; // Decode the private key into its binary format $decodedKey = base64_decode(str_replace(['-', '_'], ['+', '/'], $this->privateKey)); // Create a signature using the private key and the URL-encoded // string using HMAC SHA1. This signature will be binary. $signature = hash_hmac('sha1', $urlPartToSign, $decodedKey, true); $encodedSignature = str_replace(['+', '/'], ['-', '_'], base64_encode($signature)); return sprintf('%s&signature=%s', $query, $encodedSignature); }
[ "private", "function", "signQuery", "(", "string", "$", "query", ")", ":", "string", "{", "$", "url", "=", "parse_url", "(", "$", "query", ")", ";", "$", "urlPartToSign", "=", "$", "url", "[", "'path'", "]", ".", "'?'", ".", "$", "url", "[", "'quer...
Sign a URL with a given crypto key Note that this URL must be properly URL-encoded src: http://gmaps-samples.googlecode.com/svn/trunk/urlsigning/UrlSigner.php-source. @param string $query Query to be signed @return string $query query with signature appended
[ "Sign", "a", "URL", "with", "a", "given", "crypto", "key", "Note", "that", "this", "URL", "must", "be", "properly", "URL", "-", "encoded", "src", ":", "http", ":", "//", "gmaps", "-", "samples", ".", "googlecode", ".", "com", "/", "svn", "/", "trunk"...
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/GoogleMaps.php#L357-L373
geocoder-php/google-maps-provider
GoogleMaps.php
GoogleMaps.serializeComponents
private function serializeComponents(array $components): string { return implode('|', array_map(function ($name, $value) { return sprintf('%s:%s', $name, $value); }, array_keys($components), $components)); }
php
private function serializeComponents(array $components): string { return implode('|', array_map(function ($name, $value) { return sprintf('%s:%s', $name, $value); }, array_keys($components), $components)); }
[ "private", "function", "serializeComponents", "(", "array", "$", "components", ")", ":", "string", "{", "return", "implode", "(", "'|'", ",", "array_map", "(", "function", "(", "$", "name", ",", "$", "value", ")", "{", "return", "sprintf", "(", "'%s:%s'", ...
Serialize the component query parameter. @param array $components @return string
[ "Serialize", "the", "component", "query", "parameter", "." ]
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/GoogleMaps.php#L382-L387
geocoder-php/google-maps-provider
GoogleMaps.php
GoogleMaps.validateResponse
private function validateResponse(string $url, $content) { // Throw exception if invalid clientID and/or privateKey used with GoogleMapsBusinessProvider if (false !== strpos($content, "Provided 'signature' is not valid for the provided client ID")) { throw new InvalidCredentials(sprintf('Invalid client ID / API Key %s', $url)); } $json = json_decode($content); // API error if (!isset($json)) { throw InvalidServerResponse::create($url); } if ('REQUEST_DENIED' === $json->status && 'The provided API key is invalid.' === $json->error_message) { throw new InvalidCredentials(sprintf('API key is invalid %s', $url)); } if ('REQUEST_DENIED' === $json->status) { throw new InvalidServerResponse( sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_message) ); } // you are over your quota if ('OVER_QUERY_LIMIT' === $json->status) { throw new QuotaExceeded(sprintf('Daily quota exceeded %s', $url)); } return $json; }
php
private function validateResponse(string $url, $content) { // Throw exception if invalid clientID and/or privateKey used with GoogleMapsBusinessProvider if (false !== strpos($content, "Provided 'signature' is not valid for the provided client ID")) { throw new InvalidCredentials(sprintf('Invalid client ID / API Key %s', $url)); } $json = json_decode($content); // API error if (!isset($json)) { throw InvalidServerResponse::create($url); } if ('REQUEST_DENIED' === $json->status && 'The provided API key is invalid.' === $json->error_message) { throw new InvalidCredentials(sprintf('API key is invalid %s', $url)); } if ('REQUEST_DENIED' === $json->status) { throw new InvalidServerResponse( sprintf('API access denied. Request: %s - Message: %s', $url, $json->error_message) ); } // you are over your quota if ('OVER_QUERY_LIMIT' === $json->status) { throw new QuotaExceeded(sprintf('Daily quota exceeded %s', $url)); } return $json; }
[ "private", "function", "validateResponse", "(", "string", "$", "url", ",", "$", "content", ")", "{", "// Throw exception if invalid clientID and/or privateKey used with GoogleMapsBusinessProvider", "if", "(", "false", "!==", "strpos", "(", "$", "content", ",", "\"Provided...
Decode the response content and validate it to make sure it does not have any errors. @param string $url @param string $content @return mixed result form json_decode() @throws InvalidCredentials @throws InvalidServerResponse @throws QuotaExceeded
[ "Decode", "the", "response", "content", "and", "validate", "it", "to", "make", "sure", "it", "does", "not", "have", "any", "errors", "." ]
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/GoogleMaps.php#L401-L431
geocoder-php/google-maps-provider
GoogleMaps.php
GoogleMaps.parseCoordinates
private function parseCoordinates(AddressBuilder $builder, $result) { $coordinates = $result->geometry->location; $builder->setCoordinates($coordinates->lat, $coordinates->lng); if (isset($result->geometry->bounds)) { $builder->setBounds( $result->geometry->bounds->southwest->lat, $result->geometry->bounds->southwest->lng, $result->geometry->bounds->northeast->lat, $result->geometry->bounds->northeast->lng ); } elseif (isset($result->geometry->viewport)) { $builder->setBounds( $result->geometry->viewport->southwest->lat, $result->geometry->viewport->southwest->lng, $result->geometry->viewport->northeast->lat, $result->geometry->viewport->northeast->lng ); } elseif ('ROOFTOP' === $result->geometry->location_type) { // Fake bounds $builder->setBounds( $coordinates->lat, $coordinates->lng, $coordinates->lat, $coordinates->lng ); } }
php
private function parseCoordinates(AddressBuilder $builder, $result) { $coordinates = $result->geometry->location; $builder->setCoordinates($coordinates->lat, $coordinates->lng); if (isset($result->geometry->bounds)) { $builder->setBounds( $result->geometry->bounds->southwest->lat, $result->geometry->bounds->southwest->lng, $result->geometry->bounds->northeast->lat, $result->geometry->bounds->northeast->lng ); } elseif (isset($result->geometry->viewport)) { $builder->setBounds( $result->geometry->viewport->southwest->lat, $result->geometry->viewport->southwest->lng, $result->geometry->viewport->northeast->lat, $result->geometry->viewport->northeast->lng ); } elseif ('ROOFTOP' === $result->geometry->location_type) { // Fake bounds $builder->setBounds( $coordinates->lat, $coordinates->lng, $coordinates->lat, $coordinates->lng ); } }
[ "private", "function", "parseCoordinates", "(", "AddressBuilder", "$", "builder", ",", "$", "result", ")", "{", "$", "coordinates", "=", "$", "result", "->", "geometry", "->", "location", ";", "$", "builder", "->", "setCoordinates", "(", "$", "coordinates", ...
Parse coordinats and bounds. @param AddressBuilder $builder @param $result
[ "Parse", "coordinats", "and", "bounds", "." ]
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/GoogleMaps.php#L439-L467
geocoder-php/google-maps-provider
Model/GoogleAddress.php
GoogleAddress.withSubLocalityLevels
public function withSubLocalityLevels(array $subLocalityLevel) { $subLocalityLevels = []; foreach ($subLocalityLevel as $level) { if (empty($level['level'])) { continue; } $name = $level['name'] ?? $level['code'] ?? ''; if (empty($name)) { continue; } $subLocalityLevels[] = new AdminLevel($level['level'], $name, $level['code'] ?? null); } $subLocalityLevels = array_unique($subLocalityLevels); $new = clone $this; $new->subLocalityLevels = new AdminLevelCollection($subLocalityLevels); return $new; }
php
public function withSubLocalityLevels(array $subLocalityLevel) { $subLocalityLevels = []; foreach ($subLocalityLevel as $level) { if (empty($level['level'])) { continue; } $name = $level['name'] ?? $level['code'] ?? ''; if (empty($name)) { continue; } $subLocalityLevels[] = new AdminLevel($level['level'], $name, $level['code'] ?? null); } $subLocalityLevels = array_unique($subLocalityLevels); $new = clone $this; $new->subLocalityLevels = new AdminLevelCollection($subLocalityLevels); return $new; }
[ "public", "function", "withSubLocalityLevels", "(", "array", "$", "subLocalityLevel", ")", "{", "$", "subLocalityLevels", "=", "[", "]", ";", "foreach", "(", "$", "subLocalityLevel", "as", "$", "level", ")", "{", "if", "(", "empty", "(", "$", "level", "[",...
@param array $subLocalityLevel @return $this
[ "@param", "array", "$subLocalityLevel" ]
train
https://github.com/geocoder-php/google-maps-provider/blob/307ca3590b67d23d0658808bb3615f2be3154eee/Model/GoogleAddress.php#L491-L513
mihaeu/dephpend
src/OS/ShellWrapper.php
ShellWrapper.run
public function run(string $command) : int { $output = []; $returnVar = 1; $command .= $this->isWindows() ? $this->STD_ERR_PIPE_WIN : $this->STD_ERR_PIPE; exec($command, $output, $returnVar); return $returnVar; }
php
public function run(string $command) : int { $output = []; $returnVar = 1; $command .= $this->isWindows() ? $this->STD_ERR_PIPE_WIN : $this->STD_ERR_PIPE; exec($command, $output, $returnVar); return $returnVar; }
[ "public", "function", "run", "(", "string", "$", "command", ")", ":", "int", "{", "$", "output", "=", "[", "]", ";", "$", "returnVar", "=", "1", ";", "$", "command", ".=", "$", "this", "->", "isWindows", "(", ")", "?", "$", "this", "->", "STD_ERR...
@param string $command @return int return var
[ "@param", "string", "$command" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/OS/ShellWrapper.php#L18-L28
mihaeu/dephpend
src/Dependencies/DependencyMap.php
DependencyMap.add
public function add(Dependency $from, Dependency $to) : self { $clone = clone $this; if ($from->equals($to) || $from->count() === 0 || $to->count() === 0 || \in_array($to->toString(), ['self', 'parent', 'static'])) { return $clone; } if (array_key_exists($from->toString(), $clone->map)) { $clone->map[$from->toString()][self::$VALUE] = $clone->map[$from->toString()][self::$VALUE]->add($to); } else { $clone->map[$from->toString()] = [ self::$KEY => $from, self::$VALUE => (new DependencySet())->add($to), ]; } return $clone; }
php
public function add(Dependency $from, Dependency $to) : self { $clone = clone $this; if ($from->equals($to) || $from->count() === 0 || $to->count() === 0 || \in_array($to->toString(), ['self', 'parent', 'static'])) { return $clone; } if (array_key_exists($from->toString(), $clone->map)) { $clone->map[$from->toString()][self::$VALUE] = $clone->map[$from->toString()][self::$VALUE]->add($to); } else { $clone->map[$from->toString()] = [ self::$KEY => $from, self::$VALUE => (new DependencySet())->add($to), ]; } return $clone; }
[ "public", "function", "add", "(", "Dependency", "$", "from", ",", "Dependency", "$", "to", ")", ":", "self", "{", "$", "clone", "=", "clone", "$", "this", ";", "if", "(", "$", "from", "->", "equals", "(", "$", "to", ")", "||", "$", "from", "->", ...
@param Dependency $from @param Dependency $to @return DependencyMap
[ "@param", "Dependency", "$from", "@param", "Dependency", "$to" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Dependencies/DependencyMap.php#L17-L36
mihaeu/dephpend
src/Dependencies/DependencyMap.php
DependencyMap.reduceEachDependency
public function reduceEachDependency(\Closure $mappers) : DependencyMap { return $this->reduce(new self(), function (self $map, Dependency $from, Dependency $to) use ($mappers) { return $map->add($mappers($from), $mappers($to)); }); }
php
public function reduceEachDependency(\Closure $mappers) : DependencyMap { return $this->reduce(new self(), function (self $map, Dependency $from, Dependency $to) use ($mappers) { return $map->add($mappers($from), $mappers($to)); }); }
[ "public", "function", "reduceEachDependency", "(", "\\", "Closure", "$", "mappers", ")", ":", "DependencyMap", "{", "return", "$", "this", "->", "reduce", "(", "new", "self", "(", ")", ",", "function", "(", "self", "$", "map", ",", "Dependency", "$", "fr...
This variant of reduce takes a \Closure which takes only a single Dependency (as opposed to a pair of $to and $from) and applies it to both $to and $from. @param \Closure $mappers @return DependencyMap
[ "This", "variant", "of", "reduce", "takes", "a", "\\", "Closure", "which", "takes", "only", "a", "single", "Dependency", "(", "as", "opposed", "to", "a", "pair", "of", "$to", "and", "$from", ")", "and", "applies", "it", "to", "both", "$to", "and", "$fr...
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Dependencies/DependencyMap.php#L91-L96
mihaeu/dephpend
src/Util/Util.php
Util.array_once
public static function array_once(array $xs, \Closure $fn) : bool { foreach ($xs as $index => $value) { if ($fn($value, $index)) { return true; } } return false; }
php
public static function array_once(array $xs, \Closure $fn) : bool { foreach ($xs as $index => $value) { if ($fn($value, $index)) { return true; } } return false; }
[ "public", "static", "function", "array_once", "(", "array", "$", "xs", ",", "\\", "Closure", "$", "fn", ")", ":", "bool", "{", "foreach", "(", "$", "xs", "as", "$", "index", "=>", "$", "value", ")", "{", "if", "(", "$", "fn", "(", "$", "value", ...
@param array $xs @param \Closure $fn Tests every element of xs against this function. The first parameter is the value of the current element, the second is the index of the current element @return bool
[ "@param", "array", "$xs", "@param", "\\", "Closure", "$fn", "Tests", "every", "element", "of", "xs", "against", "this", "function", ".", "The", "first", "parameter", "is", "the", "value", "of", "the", "current", "element", "the", "second", "is", "the", "in...
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Util/Util.php#L18-L27
mihaeu/dephpend
src/Util/Util.php
Util.reduce
public static function reduce(array $xs, \Closure $fn, $initial) { foreach ($xs as $key => $value) { $initial = $fn($initial, $key, $value); } return $initial; }
php
public static function reduce(array $xs, \Closure $fn, $initial) { foreach ($xs as $key => $value) { $initial = $fn($initial, $key, $value); } return $initial; }
[ "public", "static", "function", "reduce", "(", "array", "$", "xs", ",", "\\", "Closure", "$", "fn", ",", "$", "initial", ")", "{", "foreach", "(", "$", "xs", "as", "$", "key", "=>", "$", "value", ")", "{", "$", "initial", "=", "$", "fn", "(", "...
PHP's array_reduce does not provide access to the key. This function does the same as array produce, while providing access to the key. @param array $xs @param \Closure $fn (mixed $carry, int|string $key, mixed $value) @param $initial @return mixed
[ "PHP", "s", "array_reduce", "does", "not", "provide", "access", "to", "the", "key", ".", "This", "function", "does", "the", "same", "as", "array", "produce", "while", "providing", "access", "to", "the", "key", "." ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Util/Util.php#L39-L45
mihaeu/dephpend
src/Formatters/DependencyStructureMatrixBuilder.php
DependencyStructureMatrixBuilder.createEmptyDsm
private function createEmptyDsm(DependencySet $dependencies) { return $dependencies->reduce([], function (array $combined, Dependency $dependency) use ($dependencies) { $combined[$dependency->toString()] = array_combine( array_values($dependencies->toArray()), // keys: dependency name array_pad([], $dependencies->count(), 0) // values: [0, 0, 0, ... , 0] ); return $combined; }); }
php
private function createEmptyDsm(DependencySet $dependencies) { return $dependencies->reduce([], function (array $combined, Dependency $dependency) use ($dependencies) { $combined[$dependency->toString()] = array_combine( array_values($dependencies->toArray()), // keys: dependency name array_pad([], $dependencies->count(), 0) // values: [0, 0, 0, ... , 0] ); return $combined; }); }
[ "private", "function", "createEmptyDsm", "(", "DependencySet", "$", "dependencies", ")", "{", "return", "$", "dependencies", "->", "reduce", "(", "[", "]", ",", "function", "(", "array", "$", "combined", ",", "Dependency", "$", "dependency", ")", "use", "(",...
@param $dependencies @return array
[ "@param", "$dependencies" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Formatters/DependencyStructureMatrixBuilder.php#L29-L38
mihaeu/dephpend
src/Analyser/Metrics.php
Metrics.abstractness
public function abstractness(DependencyMap $map) : float { $abstractions = $this->abstractClassCount($map) + $this->interfaceCount($map) + $this->traitCount($map); if ($abstractions === 0) { return 0; } $allClasses = $abstractions + $this->classCount($map); return $abstractions / $allClasses; }
php
public function abstractness(DependencyMap $map) : float { $abstractions = $this->abstractClassCount($map) + $this->interfaceCount($map) + $this->traitCount($map); if ($abstractions === 0) { return 0; } $allClasses = $abstractions + $this->classCount($map); return $abstractions / $allClasses; }
[ "public", "function", "abstractness", "(", "DependencyMap", "$", "map", ")", ":", "float", "{", "$", "abstractions", "=", "$", "this", "->", "abstractClassCount", "(", "$", "map", ")", "+", "$", "this", "->", "interfaceCount", "(", "$", "map", ")", "+", ...
@param DependencyMap $map @return float Value from 0 (completely concrete) to 1 (completely abstract)
[ "@param", "DependencyMap", "$map" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Analyser/Metrics.php#L21-L31
mihaeu/dephpend
src/Analyser/Metrics.php
Metrics.afferentCoupling
public function afferentCoupling(DependencyMap $map) : array { return $map->fromDependencies()->reduce([], function (array $afferent, Dependency $from) use ($map) { $afferent[$from->toString()] = $map->reduce( 0, function (int $count, Dependency $fromOther, Dependency $to) use ($from): int { return $from->equals($to) ? $count + 1 : $count; } ); return $afferent; }); }
php
public function afferentCoupling(DependencyMap $map) : array { return $map->fromDependencies()->reduce([], function (array $afferent, Dependency $from) use ($map) { $afferent[$from->toString()] = $map->reduce( 0, function (int $count, Dependency $fromOther, Dependency $to) use ($from): int { return $from->equals($to) ? $count + 1 : $count; } ); return $afferent; }); }
[ "public", "function", "afferentCoupling", "(", "DependencyMap", "$", "map", ")", ":", "array", "{", "return", "$", "map", "->", "fromDependencies", "(", ")", "->", "reduce", "(", "[", "]", ",", "function", "(", "array", "$", "afferent", ",", "Dependency", ...
Afferent coupling is an indicator for the responsibility of a package. @param DependencyMap $map @return array
[ "Afferent", "coupling", "is", "an", "indicator", "for", "the", "responsibility", "of", "a", "package", "." ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Analyser/Metrics.php#L68-L81
mihaeu/dephpend
src/Analyser/Metrics.php
Metrics.efferentCoupling
public function efferentCoupling(DependencyMap $map) : array { return $map->reduce([], function (array $efferent, Dependency $from, Dependency $to) use ($map) { $efferent[$from->toString()] = $map->get($from)->count(); return $efferent; }); }
php
public function efferentCoupling(DependencyMap $map) : array { return $map->reduce([], function (array $efferent, Dependency $from, Dependency $to) use ($map) { $efferent[$from->toString()] = $map->get($from)->count(); return $efferent; }); }
[ "public", "function", "efferentCoupling", "(", "DependencyMap", "$", "map", ")", ":", "array", "{", "return", "$", "map", "->", "reduce", "(", "[", "]", ",", "function", "(", "array", "$", "efferent", ",", "Dependency", "$", "from", ",", "Dependency", "$...
Efferent coupling is an indicator for how independent a package is. @param DependencyMap $map @return array
[ "Efferent", "coupling", "is", "an", "indicator", "for", "how", "independent", "a", "package", "is", "." ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Analyser/Metrics.php#L90-L96
mihaeu/dephpend
src/Analyser/Metrics.php
Metrics.instability
public function instability(DependencyMap $map) : array { $ce = $this->efferentCoupling($map); $ca = $this->afferentCoupling($map); $instability = []; foreach ($ce as $class => $count) { $totalCoupling = $ce[$class] + $ca[$class]; $instability[$class] = $ce[$class] / $totalCoupling; } return $instability; }
php
public function instability(DependencyMap $map) : array { $ce = $this->efferentCoupling($map); $ca = $this->afferentCoupling($map); $instability = []; foreach ($ce as $class => $count) { $totalCoupling = $ce[$class] + $ca[$class]; $instability[$class] = $ce[$class] / $totalCoupling; } return $instability; }
[ "public", "function", "instability", "(", "DependencyMap", "$", "map", ")", ":", "array", "{", "$", "ce", "=", "$", "this", "->", "efferentCoupling", "(", "$", "map", ")", ";", "$", "ca", "=", "$", "this", "->", "afferentCoupling", "(", "$", "map", "...
Instability is an indicator for how resilient a package is towards change. @param DependencyMap $map @return array Key: Class Value: Range from 0 (completely stable) to 1 (completely unstable)
[ "Instability", "is", "an", "indicator", "for", "how", "resilient", "a", "package", "is", "towards", "change", "." ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Analyser/Metrics.php#L105-L115
mihaeu/dephpend
src/Util/AbstractCollection.php
AbstractCollection.any
public function any(\Closure $closure) : bool { foreach ($this->collection as $item) { if ($closure($item) === true) { return true; } } return false; }
php
public function any(\Closure $closure) : bool { foreach ($this->collection as $item) { if ($closure($item) === true) { return true; } } return false; }
[ "public", "function", "any", "(", "\\", "Closure", "$", "closure", ")", ":", "bool", "{", "foreach", "(", "$", "this", "->", "collection", "as", "$", "item", ")", "{", "if", "(", "$", "closure", "(", "$", "item", ")", "===", "true", ")", "{", "re...
{@inheritdoc}
[ "{" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Util/AbstractCollection.php#L15-L24
mihaeu/dephpend
src/Util/AbstractCollection.php
AbstractCollection.filter
public function filter(\Closure $closure) : Collection { $clone = clone $this; $clone->collection = array_values(array_filter($this->collection, $closure)); return $clone; }
php
public function filter(\Closure $closure) : Collection { $clone = clone $this; $clone->collection = array_values(array_filter($this->collection, $closure)); return $clone; }
[ "public", "function", "filter", "(", "\\", "Closure", "$", "closure", ")", ":", "Collection", "{", "$", "clone", "=", "clone", "$", "this", ";", "$", "clone", "->", "collection", "=", "array_values", "(", "array_filter", "(", "$", "this", "->", "collecti...
{@inheritdoc}
[ "{" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Util/AbstractCollection.php#L65-L71
mihaeu/dephpend
src/Cli/Application.php
Application.doRun
public function doRun(InputInterface $input, OutputInterface $output) { $this->printWarningIfXdebugIsEnabled($output); try { parent::doRun($input, $output); } catch (ParserException $e) { $output->writeln('<error>Sorry, we could not analyse your dependencies, ' . 'because the sources contain syntax errors:' . PHP_EOL . PHP_EOL . $e->getMessage() . ' in file ' . $e->getFile() . '<error>'); return $e->getCode() ?? 1; } catch (\Throwable $e) { if ($output !== null) { $output->writeln( "<error>Something went wrong, this shouldn't happen." . ' Please take a minute and report this issue:' . ' https://github.com/mihaeu/dephpend/issues</error>' . PHP_EOL . PHP_EOL . $e->getMessage() . PHP_EOL . PHP_EOL . "[{$e->getFile()} at line {$e->getLine()}]" ); } return $e->getCode() ?? 1; } return 0; }
php
public function doRun(InputInterface $input, OutputInterface $output) { $this->printWarningIfXdebugIsEnabled($output); try { parent::doRun($input, $output); } catch (ParserException $e) { $output->writeln('<error>Sorry, we could not analyse your dependencies, ' . 'because the sources contain syntax errors:' . PHP_EOL . PHP_EOL . $e->getMessage() . ' in file ' . $e->getFile() . '<error>'); return $e->getCode() ?? 1; } catch (\Throwable $e) { if ($output !== null) { $output->writeln( "<error>Something went wrong, this shouldn't happen." . ' Please take a minute and report this issue:' . ' https://github.com/mihaeu/dephpend/issues</error>' . PHP_EOL . PHP_EOL . $e->getMessage() . PHP_EOL . PHP_EOL . "[{$e->getFile()} at line {$e->getLine()}]" ); } return $e->getCode() ?? 1; } return 0; }
[ "public", "function", "doRun", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "this", "->", "printWarningIfXdebugIsEnabled", "(", "$", "output", ")", ";", "try", "{", "parent", "::", "doRun", "(", "$", "input", "...
Commands are added here instead of before executing run(), because we need access to command line options in order to inject the right dependencies. @param InputInterface $input @param OutputInterface $output @return int @throws \Symfony\Component\Console\Exception\LogicException
[ "Commands", "are", "added", "here", "instead", "of", "before", "executing", "run", "()", "because", "we", "need", "access", "to", "command", "line", "options", "in", "order", "to", "inject", "the", "right", "dependencies", "." ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Cli/Application.php#L37-L64
mihaeu/dephpend
src/Formatters/PlantUmlFormatter.php
PlantUmlFormatter.format
public function format(DependencyMap $map, \Closure $mappers = null) : string { return '@startuml'.PHP_EOL .$this->plantUmlNamespaceDefinitions($map).PHP_EOL .$this->dependenciesInPlantUmlFormat($map).PHP_EOL .'@enduml'; }
php
public function format(DependencyMap $map, \Closure $mappers = null) : string { return '@startuml'.PHP_EOL .$this->plantUmlNamespaceDefinitions($map).PHP_EOL .$this->dependenciesInPlantUmlFormat($map).PHP_EOL .'@enduml'; }
[ "public", "function", "format", "(", "DependencyMap", "$", "map", ",", "\\", "Closure", "$", "mappers", "=", "null", ")", ":", "string", "{", "return", "'@startuml'", ".", "PHP_EOL", ".", "$", "this", "->", "plantUmlNamespaceDefinitions", "(", "$", "map", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Formatters/PlantUmlFormatter.php#L18-L24
mihaeu/dephpend
src/Dependencies/DependencyFactory.php
DependencyFactory.createClazzFromStringArray
final public function createClazzFromStringArray(array $parts) : Dependency { try { $clazz = new Clazz( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); } catch (\InvalidArgumentException $exception) { $clazz = new NullDependency(); } return $clazz; }
php
final public function createClazzFromStringArray(array $parts) : Dependency { try { $clazz = new Clazz( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); } catch (\InvalidArgumentException $exception) { $clazz = new NullDependency(); } return $clazz; }
[ "final", "public", "function", "createClazzFromStringArray", "(", "array", "$", "parts", ")", ":", "Dependency", "{", "try", "{", "$", "clazz", "=", "new", "Clazz", "(", "$", "this", "->", "extractClazzPart", "(", "$", "parts", ")", ",", "new", "Namespaze"...
@param array $parts @return Dependency
[ "@param", "array", "$parts" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Dependencies/DependencyFactory.php#L14-L25
mihaeu/dephpend
src/Dependencies/DependencyFactory.php
DependencyFactory.createAbstractClazzFromStringArray
final public function createAbstractClazzFromStringArray(array $parts) : AbstractClazz { return new AbstractClazz( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); }
php
final public function createAbstractClazzFromStringArray(array $parts) : AbstractClazz { return new AbstractClazz( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); }
[ "final", "public", "function", "createAbstractClazzFromStringArray", "(", "array", "$", "parts", ")", ":", "AbstractClazz", "{", "return", "new", "AbstractClazz", "(", "$", "this", "->", "extractClazzPart", "(", "$", "parts", ")", ",", "new", "Namespaze", "(", ...
@param array $parts @return AbstractClazz
[ "@param", "array", "$parts" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Dependencies/DependencyFactory.php#L32-L38
mihaeu/dephpend
src/Dependencies/DependencyFactory.php
DependencyFactory.createInterfazeFromStringArray
final public function createInterfazeFromStringArray(array $parts) : Interfaze { return new Interfaze( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); }
php
final public function createInterfazeFromStringArray(array $parts) : Interfaze { return new Interfaze( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); }
[ "final", "public", "function", "createInterfazeFromStringArray", "(", "array", "$", "parts", ")", ":", "Interfaze", "{", "return", "new", "Interfaze", "(", "$", "this", "->", "extractClazzPart", "(", "$", "parts", ")", ",", "new", "Namespaze", "(", "$", "thi...
@param array $parts @return Interfaze
[ "@param", "array", "$parts" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Dependencies/DependencyFactory.php#L45-L51
mihaeu/dephpend
src/Dependencies/DependencyFactory.php
DependencyFactory.createTraitFromStringArray
final public function createTraitFromStringArray(array $parts) : Trait_ { return new Trait_( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); }
php
final public function createTraitFromStringArray(array $parts) : Trait_ { return new Trait_( $this->extractClazzPart($parts), new Namespaze($this->extractNamespaceParts($parts)) ); }
[ "final", "public", "function", "createTraitFromStringArray", "(", "array", "$", "parts", ")", ":", "Trait_", "{", "return", "new", "Trait_", "(", "$", "this", "->", "extractClazzPart", "(", "$", "parts", ")", ",", "new", "Namespaze", "(", "$", "this", "->"...
@param array $parts @return Trait_
[ "@param", "array", "$parts" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Dependencies/DependencyFactory.php#L58-L64
mihaeu/dephpend
src/OS/PlantUmlWrapper.php
PlantUmlWrapper.generate
public function generate(DependencyMap $map, \SplFileInfo $destination, bool $keepUml = false) { $this->ensurePlantUmlIsInstalled($this->shell); $umlDestination = preg_replace('/\.\w+$/', '.uml', $destination->getPathname()); file_put_contents($umlDestination, $this->plantUmlFormatter->format($map)); $this->shell->run('plantuml ' . $umlDestination); if ($keepUml === false) { unlink($umlDestination); } }
php
public function generate(DependencyMap $map, \SplFileInfo $destination, bool $keepUml = false) { $this->ensurePlantUmlIsInstalled($this->shell); $umlDestination = preg_replace('/\.\w+$/', '.uml', $destination->getPathname()); file_put_contents($umlDestination, $this->plantUmlFormatter->format($map)); $this->shell->run('plantuml ' . $umlDestination); if ($keepUml === false) { unlink($umlDestination); } }
[ "public", "function", "generate", "(", "DependencyMap", "$", "map", ",", "\\", "SplFileInfo", "$", "destination", ",", "bool", "$", "keepUml", "=", "false", ")", "{", "$", "this", "->", "ensurePlantUmlIsInstalled", "(", "$", "this", "->", "shell", ")", ";"...
@param DependencyMap $map @param \SplFileInfo $destination @param bool $keepUml @throws PlantUmlNotInstalledException
[ "@param", "DependencyMap", "$map", "@param", "\\", "SplFileInfo", "$destination", "@param", "bool", "$keepUml" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/OS/PlantUmlWrapper.php#L36-L47
mihaeu/dephpend
src/Cli/MetricsCommand.php
MetricsCommand.execute
protected function execute(InputInterface $input, OutputInterface $output) { $table = new Table($output); $table->setRows([ ['Classes: ', $this->metrics->classCount($this->dependencies)], ['Abstract classes: ', $this->metrics->abstractClassCount($this->dependencies)], ['Interfaces: ', $this->metrics->interfaceCount($this->dependencies)], ['Traits: ', $this->metrics->traitCount($this->dependencies)], ['Abstractness: ', sprintf('%.3f', $this->metrics->abstractness($this->dependencies))], ]); $table->render(); $table = new Table($output); $table->setHeaders(['', 'Afferent Coupling', 'Efferent Coupling', 'Instability']); $table->setRows($this->combineMetrics( $this->metrics->afferentCoupling($this->dependencies), $this->metrics->efferentCoupling($this->dependencies), $this->metrics->instability($this->dependencies) )); $table->render(); }
php
protected function execute(InputInterface $input, OutputInterface $output) { $table = new Table($output); $table->setRows([ ['Classes: ', $this->metrics->classCount($this->dependencies)], ['Abstract classes: ', $this->metrics->abstractClassCount($this->dependencies)], ['Interfaces: ', $this->metrics->interfaceCount($this->dependencies)], ['Traits: ', $this->metrics->traitCount($this->dependencies)], ['Abstractness: ', sprintf('%.3f', $this->metrics->abstractness($this->dependencies))], ]); $table->render(); $table = new Table($output); $table->setHeaders(['', 'Afferent Coupling', 'Efferent Coupling', 'Instability']); $table->setRows($this->combineMetrics( $this->metrics->afferentCoupling($this->dependencies), $this->metrics->efferentCoupling($this->dependencies), $this->metrics->instability($this->dependencies) )); $table->render(); }
[ "protected", "function", "execute", "(", "InputInterface", "$", "input", ",", "OutputInterface", "$", "output", ")", "{", "$", "table", "=", "new", "Table", "(", "$", "output", ")", ";", "$", "table", "->", "setRows", "(", "[", "[", "'Classes: '", ",", ...
{@inheritdoc} @throws \Symfony\Component\Console\Exception\InvalidArgumentException
[ "{", "@inheritdoc", "}" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Cli/MetricsCommand.php#L37-L57
mihaeu/dephpend
src/Analyser/DependencyInspectionVisitor.php
DependencyInspectionVisitor.enterNode
public function enterNode(Node $node) { if ($node instanceof ClassLikeNode) { $this->setCurrentClass($node); if ($this->isSubclass($node)) { $this->addParentDependency($node); } if ($node instanceof ClassNode) { $this->addImplementedInterfaceDependency($node); } } elseif ($node instanceof NewNode && $node->class instanceof NameNode) { $this->addName($node->class); } elseif ($node instanceof ClassMethodNode) { $this->addInjectedDependencies($node); $this->addReturnType($node); } elseif ($node instanceof UseNode) { foreach ($node->uses as $use) { $this->addName($use->name); } } elseif ($node instanceof StaticCallNode && $node->class instanceof NameNode) { $this->addStaticDependency($node); } elseif ($node instanceof UseTraitNode) { foreach ($node->traits as $trait) { $this->addName($trait); } } elseif ($node instanceof InstanceofNode) { $this->addInstanceofDependency($node); } elseif ($node instanceof FetchClassConstantNode && !$node->class instanceof Node\Expr\Variable) { $this->addName($node->class); } elseif ($node instanceof CatchNode) { foreach ($node->types as $name) { $this->addName($name); } } }
php
public function enterNode(Node $node) { if ($node instanceof ClassLikeNode) { $this->setCurrentClass($node); if ($this->isSubclass($node)) { $this->addParentDependency($node); } if ($node instanceof ClassNode) { $this->addImplementedInterfaceDependency($node); } } elseif ($node instanceof NewNode && $node->class instanceof NameNode) { $this->addName($node->class); } elseif ($node instanceof ClassMethodNode) { $this->addInjectedDependencies($node); $this->addReturnType($node); } elseif ($node instanceof UseNode) { foreach ($node->uses as $use) { $this->addName($use->name); } } elseif ($node instanceof StaticCallNode && $node->class instanceof NameNode) { $this->addStaticDependency($node); } elseif ($node instanceof UseTraitNode) { foreach ($node->traits as $trait) { $this->addName($trait); } } elseif ($node instanceof InstanceofNode) { $this->addInstanceofDependency($node); } elseif ($node instanceof FetchClassConstantNode && !$node->class instanceof Node\Expr\Variable) { $this->addName($node->class); } elseif ($node instanceof CatchNode) { foreach ($node->types as $name) { $this->addName($name); } } }
[ "public", "function", "enterNode", "(", "Node", "$", "node", ")", "{", "if", "(", "$", "node", "instanceof", "ClassLikeNode", ")", "{", "$", "this", "->", "setCurrentClass", "(", "$", "node", ")", ";", "if", "(", "$", "this", "->", "isSubclass", "(", ...
{@inheritdoc}
[ "{" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Analyser/DependencyInspectionVisitor.php#L56-L95
mihaeu/dephpend
src/Analyser/DependencyInspectionVisitor.php
DependencyInspectionVisitor.leaveNode
public function leaveNode(Node $node) { if (!$node instanceof ClassLikeNode) { return null; } // not in class context if ($this->currentClass === null) { $this->tempDependencies = new DependencySet(); return; } // by now the class should have been parsed so replace the // temporary class with the parsed class name $this->dependencies = $this->dependencies->addSet( $this->currentClass, $this->tempDependencies ); $this->tempDependencies = new DependencySet(); $this->currentClass = null; }
php
public function leaveNode(Node $node) { if (!$node instanceof ClassLikeNode) { return null; } // not in class context if ($this->currentClass === null) { $this->tempDependencies = new DependencySet(); return; } // by now the class should have been parsed so replace the // temporary class with the parsed class name $this->dependencies = $this->dependencies->addSet( $this->currentClass, $this->tempDependencies ); $this->tempDependencies = new DependencySet(); $this->currentClass = null; }
[ "public", "function", "leaveNode", "(", "Node", "$", "node", ")", "{", "if", "(", "!", "$", "node", "instanceof", "ClassLikeNode", ")", "{", "return", "null", ";", "}", "// not in class context", "if", "(", "$", "this", "->", "currentClass", "===", "null",...
As described in beforeTraverse we are going to update the class we are currently parsing for all dependencies. If we are not in class context we won't add the dependencies. @param Node $node @return false|null|Node|\PhpParser\Node[]|void
[ "As", "described", "in", "beforeTraverse", "we", "are", "going", "to", "update", "the", "class", "we", "are", "currently", "parsing", "for", "all", "dependencies", ".", "If", "we", "are", "not", "in", "class", "context", "we", "won", "t", "add", "the", "...
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Analyser/DependencyInspectionVisitor.php#L113-L134
mihaeu/dephpend
src/Dependencies/DependencySet.php
DependencySet.add
public function add(Dependency $dependency) : DependencySet { $clone = clone $this; if ($this->contains($dependency) || $dependency->count() === 0) { return $clone; } $clone->collection[] = $dependency; return $clone; }
php
public function add(Dependency $dependency) : DependencySet { $clone = clone $this; if ($this->contains($dependency) || $dependency->count() === 0) { return $clone; } $clone->collection[] = $dependency; return $clone; }
[ "public", "function", "add", "(", "Dependency", "$", "dependency", ")", ":", "DependencySet", "{", "$", "clone", "=", "clone", "$", "this", ";", "if", "(", "$", "this", "->", "contains", "(", "$", "dependency", ")", "||", "$", "dependency", "->", "coun...
@param Dependency $dependency @return DependencySet
[ "@param", "Dependency", "$dependency" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Dependencies/DependencySet.php#L16-L26
mihaeu/dephpend
src/Cli/Dispatcher.php
Dispatcher.analyzeDependencies
private function analyzeDependencies(InputInterface $input): DependencyMap { // run static analysis $dependencies = $this->staticAnalyser->analyse( $this->phpFileFinder->getAllPhpFilesFromSources($input->getArgument('source')) ); // optional: analyse results of dynamic analysis and merge if ($input->getOption('dynamic')) { $traceFile = new \SplFileInfo($input->getOption('dynamic')); $dependencies = $dependencies->addMap( $this->xDebugFunctionTraceAnalyser->analyse($traceFile) ); } // apply pre-filters return $this->dependencyFilter->filterByOptions($dependencies, $input->getOptions()); }
php
private function analyzeDependencies(InputInterface $input): DependencyMap { // run static analysis $dependencies = $this->staticAnalyser->analyse( $this->phpFileFinder->getAllPhpFilesFromSources($input->getArgument('source')) ); // optional: analyse results of dynamic analysis and merge if ($input->getOption('dynamic')) { $traceFile = new \SplFileInfo($input->getOption('dynamic')); $dependencies = $dependencies->addMap( $this->xDebugFunctionTraceAnalyser->analyse($traceFile) ); } // apply pre-filters return $this->dependencyFilter->filterByOptions($dependencies, $input->getOptions()); }
[ "private", "function", "analyzeDependencies", "(", "InputInterface", "$", "input", ")", ":", "DependencyMap", "{", "// run static analysis", "$", "dependencies", "=", "$", "this", "->", "staticAnalyser", "->", "analyse", "(", "$", "this", "->", "phpFileFinder", "-...
@param InputInterface $input @param DependencyContainer $dependencyContainer @return DependencyMap @throws \LogicException
[ "@param", "InputInterface", "$input", "@param", "DependencyContainer", "$dependencyContainer" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Cli/Dispatcher.php#L75-L92
mihaeu/dephpend
src/OS/PhpFileFinder.php
PhpFileFinder.getAllPhpFilesFromSources
public function getAllPhpFilesFromSources(array $sources) : PhpFileSet { return array_reduce( $sources, function (PhpFileSet $set, string $source) { return $set->addAll($this->find(new \SplFileInfo($source))); }, new PhpFileSet() ); }
php
public function getAllPhpFilesFromSources(array $sources) : PhpFileSet { return array_reduce( $sources, function (PhpFileSet $set, string $source) { return $set->addAll($this->find(new \SplFileInfo($source))); }, new PhpFileSet() ); }
[ "public", "function", "getAllPhpFilesFromSources", "(", "array", "$", "sources", ")", ":", "PhpFileSet", "{", "return", "array_reduce", "(", "$", "sources", ",", "function", "(", "PhpFileSet", "$", "set", ",", "string", "$", "source", ")", "{", "return", "$"...
@param array $sources @return PhpFileSet
[ "@param", "array", "$sources" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/OS/PhpFileFinder.php#L38-L47
mihaeu/dephpend
src/Formatters/DependencyStructureMatrixHtmlFormatter.php
DependencyStructureMatrixHtmlFormatter.format
public function format(DependencyMap $all, \Closure $mappers = null) : string { return $this->buildHtmlTable( $this->dependencyStructureMatrixBuilder->buildMatrix($all, $mappers ?? Functional::id()) ); }
php
public function format(DependencyMap $all, \Closure $mappers = null) : string { return $this->buildHtmlTable( $this->dependencyStructureMatrixBuilder->buildMatrix($all, $mappers ?? Functional::id()) ); }
[ "public", "function", "format", "(", "DependencyMap", "$", "all", ",", "\\", "Closure", "$", "mappers", "=", "null", ")", ":", "string", "{", "return", "$", "this", "->", "buildHtmlTable", "(", "$", "this", "->", "dependencyStructureMatrixBuilder", "->", "bu...
{@inheritdoc}
[ "{" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Formatters/DependencyStructureMatrixHtmlFormatter.php#L26-L31
mihaeu/dephpend
src/Formatters/DependencyStructureMatrixHtmlFormatter.php
DependencyStructureMatrixHtmlFormatter.tableBody
private function tableBody(array $dependencyArray) { $output = '<tbody>'; $numIndex = 1; foreach ($dependencyArray as $dependencyRow => $dependencies) { $output .= "<tr><th>$numIndex: $dependencyRow</th>"; foreach ($dependencies as $dependencyHeader => $count) { if ($dependencyRow === $dependencyHeader) { $output .= '<td>X</td>'; } else { $output .= '<td>' . $count . '</td>'; } } $output .= '</tr>'; $numIndex += 1; } $output .= '</tbody>'; return $output; }
php
private function tableBody(array $dependencyArray) { $output = '<tbody>'; $numIndex = 1; foreach ($dependencyArray as $dependencyRow => $dependencies) { $output .= "<tr><th>$numIndex: $dependencyRow</th>"; foreach ($dependencies as $dependencyHeader => $count) { if ($dependencyRow === $dependencyHeader) { $output .= '<td>X</td>'; } else { $output .= '<td>' . $count . '</td>'; } } $output .= '</tr>'; $numIndex += 1; } $output .= '</tbody>'; return $output; }
[ "private", "function", "tableBody", "(", "array", "$", "dependencyArray", ")", "{", "$", "output", "=", "'<tbody>'", ";", "$", "numIndex", "=", "1", ";", "foreach", "(", "$", "dependencyArray", "as", "$", "dependencyRow", "=>", "$", "dependencies", ")", "{...
@param array $dependencyArray @return string
[ "@param", "array", "$dependencyArray" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Formatters/DependencyStructureMatrixHtmlFormatter.php#L118-L136
mihaeu/dephpend
src/Formatters/DependencyStructureMatrixHtmlFormatter.php
DependencyStructureMatrixHtmlFormatter.tableHead
private function tableHead(array $dependencyArray) { $output = '<thead><tr><th>X</th>'; for ($i = 1, $len = count($dependencyArray); $i <= $len; $i += 1) { $output .= "<th>$i</th>"; } return $output . '</tr></thead>'; }
php
private function tableHead(array $dependencyArray) { $output = '<thead><tr><th>X</th>'; for ($i = 1, $len = count($dependencyArray); $i <= $len; $i += 1) { $output .= "<th>$i</th>"; } return $output . '</tr></thead>'; }
[ "private", "function", "tableHead", "(", "array", "$", "dependencyArray", ")", "{", "$", "output", "=", "'<thead><tr><th>X</th>'", ";", "for", "(", "$", "i", "=", "1", ",", "$", "len", "=", "count", "(", "$", "dependencyArray", ")", ";", "$", "i", "<="...
@param array $dependencyArray @return string
[ "@param", "array", "$dependencyArray" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Formatters/DependencyStructureMatrixHtmlFormatter.php#L143-L150
mihaeu/dephpend
src/Cli/BaseCommand.php
BaseCommand.ensureOutputFormatIsValid
protected function ensureOutputFormatIsValid(string $destination) { if (!in_array(preg_replace('/.+\.(\w+)$/', '$1', $destination), $this->allowedFormats, true)) { throw new \InvalidArgumentException('Output format is not allowed ('.implode(', ', $this->allowedFormats).')'); } }
php
protected function ensureOutputFormatIsValid(string $destination) { if (!in_array(preg_replace('/.+\.(\w+)$/', '$1', $destination), $this->allowedFormats, true)) { throw new \InvalidArgumentException('Output format is not allowed ('.implode(', ', $this->allowedFormats).')'); } }
[ "protected", "function", "ensureOutputFormatIsValid", "(", "string", "$", "destination", ")", "{", "if", "(", "!", "in_array", "(", "preg_replace", "(", "'/.+\\.(\\w+)$/'", ",", "'$1'", ",", "$", "destination", ")", ",", "$", "this", "->", "allowedFormats", ",...
@param string $destination @throws \Exception
[ "@param", "string", "$destination" ]
train
https://github.com/mihaeu/dephpend/blob/9902811e056189b9cb4be56df8629738306c88d9/src/Cli/BaseCommand.php#L112-L117
martinlindhe/laravel-vue-i18n-generator
src/Commands/GenerateInclude.php
GenerateInclude.handle
public function handle() { $root = base_path() . config('vue-i18n-generator.langPath'); $config = config('vue-i18n-generator'); // options $umd = $this->option('umd'); $multipleFiles = $this->option('multi'); $withVendor = $this->option('with-vendor'); $fileName = $this->option('file-name'); $langFiles = $this->option('lang-files'); $format = $this->option('format'); $multipleLocales = $this->option('multi-locales'); if ($umd) { // if the --umd option is set, set the $format to 'umd' $format = 'umd'; } if (!$this->isValidFormat($format)) { throw new \RuntimeException('Invalid format passed: ' . $format); } if ($multipleFiles || $multipleLocales) { $files = (new Generator($config)) ->generateMultiple($root, $format, $multipleLocales); if ($config['showOutputMessages']) { $this->info("Written to : " . $files); } return; } if ($langFiles) { $langFiles = explode(',', $langFiles); } $data = (new Generator($config)) ->generateFromPath($root, $format, $withVendor, $langFiles); $jsFile = $this->getFileName($fileName); file_put_contents($jsFile, $data); if ($config['showOutputMessages']) { $this->info("Written to : " . $jsFile); } }
php
public function handle() { $root = base_path() . config('vue-i18n-generator.langPath'); $config = config('vue-i18n-generator'); // options $umd = $this->option('umd'); $multipleFiles = $this->option('multi'); $withVendor = $this->option('with-vendor'); $fileName = $this->option('file-name'); $langFiles = $this->option('lang-files'); $format = $this->option('format'); $multipleLocales = $this->option('multi-locales'); if ($umd) { // if the --umd option is set, set the $format to 'umd' $format = 'umd'; } if (!$this->isValidFormat($format)) { throw new \RuntimeException('Invalid format passed: ' . $format); } if ($multipleFiles || $multipleLocales) { $files = (new Generator($config)) ->generateMultiple($root, $format, $multipleLocales); if ($config['showOutputMessages']) { $this->info("Written to : " . $files); } return; } if ($langFiles) { $langFiles = explode(',', $langFiles); } $data = (new Generator($config)) ->generateFromPath($root, $format, $withVendor, $langFiles); $jsFile = $this->getFileName($fileName); file_put_contents($jsFile, $data); if ($config['showOutputMessages']) { $this->info("Written to : " . $jsFile); } }
[ "public", "function", "handle", "(", ")", "{", "$", "root", "=", "base_path", "(", ")", ".", "config", "(", "'vue-i18n-generator.langPath'", ")", ";", "$", "config", "=", "config", "(", "'vue-i18n-generator'", ")", ";", "// options", "$", "umd", "=", "$", ...
Execute the console command. @return mixed @throws \Exception
[ "Execute", "the", "console", "command", "." ]
train
https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/13ec5314f2fb8a33216dddeda2b1c65e7dda2fc8/src/Commands/GenerateInclude.php#L28-L76
martinlindhe/laravel-vue-i18n-generator
src/GeneratorProvider.php
GeneratorProvider.boot
public function boot() { $this->app->singleton('vue-i18n.generate', function () { return new Commands\GenerateInclude; }); $this->commands( 'vue-i18n.generate' ); $this->publishes([ __DIR__.'/config/vue-i18n-generator.php' => config_path('vue-i18n-generator.php'), ]); $this->mergeConfigFrom( __DIR__.'/config/vue-i18n-generator.php', 'vue-i18n-generator' ); }
php
public function boot() { $this->app->singleton('vue-i18n.generate', function () { return new Commands\GenerateInclude; }); $this->commands( 'vue-i18n.generate' ); $this->publishes([ __DIR__.'/config/vue-i18n-generator.php' => config_path('vue-i18n-generator.php'), ]); $this->mergeConfigFrom( __DIR__.'/config/vue-i18n-generator.php', 'vue-i18n-generator' ); }
[ "public", "function", "boot", "(", ")", "{", "$", "this", "->", "app", "->", "singleton", "(", "'vue-i18n.generate'", ",", "function", "(", ")", "{", "return", "new", "Commands", "\\", "GenerateInclude", ";", "}", ")", ";", "$", "this", "->", "commands",...
Perform post-registration booting of services. @return void
[ "Perform", "post", "-", "registration", "booting", "of", "services", "." ]
train
https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/13ec5314f2fb8a33216dddeda2b1c65e7dda2fc8/src/GeneratorProvider.php#L19-L37
martinlindhe/laravel-vue-i18n-generator
src/Generator.php
Generator.adjustVendor
private function adjustVendor($locales) { if (isset($locales['vendor'])) { foreach ($locales['vendor'] as $vendor => $data) { foreach ($data as $key => $group) { foreach ($group as $locale => $lang) { $locales[$key]['vendor'][$vendor][$locale] = $lang; } } } unset($locales['vendor']); } return $locales; }
php
private function adjustVendor($locales) { if (isset($locales['vendor'])) { foreach ($locales['vendor'] as $vendor => $data) { foreach ($data as $key => $group) { foreach ($group as $locale => $lang) { $locales[$key]['vendor'][$vendor][$locale] = $lang; } } } unset($locales['vendor']); } return $locales; }
[ "private", "function", "adjustVendor", "(", "$", "locales", ")", "{", "if", "(", "isset", "(", "$", "locales", "[", "'vendor'", "]", ")", ")", "{", "foreach", "(", "$", "locales", "[", "'vendor'", "]", "as", "$", "vendor", "=>", "$", "data", ")", "...
Adjus vendor index placement. @param array $locales @return array
[ "Adjus", "vendor", "index", "placement", "." ]
train
https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/13ec5314f2fb8a33216dddeda2b1c65e7dda2fc8/src/Generator.php#L293-L308
martinlindhe/laravel-vue-i18n-generator
src/Generator.php
Generator.adjustString
private function adjustString($s) { if (!is_string($s)) { return $s; } if ($this->config['i18nLib'] === self::VUEX_I18N) { $searchPipePattern = '/(\s)*(\|)(\s)*/'; $threeColons = ' ::: '; $s = preg_replace($searchPipePattern, $threeColons, $s); } return preg_replace_callback( '/(?<!mailto|tel):\w+/', function ($matches) { return '{' . mb_substr($matches[0], 1) . '}'; }, $s ); }
php
private function adjustString($s) { if (!is_string($s)) { return $s; } if ($this->config['i18nLib'] === self::VUEX_I18N) { $searchPipePattern = '/(\s)*(\|)(\s)*/'; $threeColons = ' ::: '; $s = preg_replace($searchPipePattern, $threeColons, $s); } return preg_replace_callback( '/(?<!mailto|tel):\w+/', function ($matches) { return '{' . mb_substr($matches[0], 1) . '}'; }, $s ); }
[ "private", "function", "adjustString", "(", "$", "s", ")", "{", "if", "(", "!", "is_string", "(", "$", "s", ")", ")", "{", "return", "$", "s", ";", "}", "if", "(", "$", "this", "->", "config", "[", "'i18nLib'", "]", "===", "self", "::", "VUEX_I18...
Turn Laravel style ":link" into vue-i18n style "{link}" or vuex-i18n style ":::". @param string $s @return string
[ "Turn", "Laravel", "style", ":", "link", "into", "vue", "-", "i18n", "style", "{", "link", "}", "or", "vuex", "-", "i18n", "style", ":::", "." ]
train
https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/13ec5314f2fb8a33216dddeda2b1c65e7dda2fc8/src/Generator.php#L316-L335
martinlindhe/laravel-vue-i18n-generator
src/Generator.php
Generator.removeExtension
private function removeExtension($filename) { $pos = mb_strrpos($filename, '.'); if ($pos === false) { return $filename; } return mb_substr($filename, 0, $pos); }
php
private function removeExtension($filename) { $pos = mb_strrpos($filename, '.'); if ($pos === false) { return $filename; } return mb_substr($filename, 0, $pos); }
[ "private", "function", "removeExtension", "(", "$", "filename", ")", "{", "$", "pos", "=", "mb_strrpos", "(", "$", "filename", ",", "'.'", ")", ";", "if", "(", "$", "pos", "===", "false", ")", "{", "return", "$", "filename", ";", "}", "return", "mb_s...
Returns filename, with extension stripped @param string $filename @return string
[ "Returns", "filename", "with", "extension", "stripped" ]
train
https://github.com/martinlindhe/laravel-vue-i18n-generator/blob/13ec5314f2fb8a33216dddeda2b1c65e7dda2fc8/src/Generator.php#L342-L350
clue/phar-composer
src/Clue/PharComposer/Package/Autoload.php
Autoload.getPsr0
public function getPsr0() { if (!isset($this->autoload['psr-0'])) { return array(); } $resources = array(); foreach ($this->autoload['psr-0'] as $namespace => $paths) { foreach($this->correctSinglePath($paths) as $path) { // TODO: this is not correct actually... should work for most repos nevertheless // TODO: we have to take target-dir into account $resources[] = $this->buildNamespacePath($namespace, $path); } } return $resources; }
php
public function getPsr0() { if (!isset($this->autoload['psr-0'])) { return array(); } $resources = array(); foreach ($this->autoload['psr-0'] as $namespace => $paths) { foreach($this->correctSinglePath($paths) as $path) { // TODO: this is not correct actually... should work for most repos nevertheless // TODO: we have to take target-dir into account $resources[] = $this->buildNamespacePath($namespace, $path); } } return $resources; }
[ "public", "function", "getPsr0", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "autoload", "[", "'psr-0'", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "resources", "=", "array", "(", ")", ";", "foreach", "(",...
returns all pathes defined by PSR-0 @return string[]
[ "returns", "all", "pathes", "defined", "by", "PSR", "-", "0" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Autoload.php#L29-L45
clue/phar-composer
src/Clue/PharComposer/Package/Package.php
Package.getBundler
public function getBundler(Logger $logger) { $bundlerName = 'complete'; if (isset($this->package['extra']['phar']['bundler'])) { $bundlerName = $this->package['extra']['phar']['bundler']; } if ($bundlerName === 'composer') { return new ExplicitBundler($this, $logger); } elseif ($bundlerName === 'complete') { return new CompleteBundler($this, $logger); } else { $logger->log('Invalid bundler "' . $bundlerName . '" specified in package "' . $this->getName() . '", will fall back to "complete" bundler'); return new CompleteBundler($this, $logger); } }
php
public function getBundler(Logger $logger) { $bundlerName = 'complete'; if (isset($this->package['extra']['phar']['bundler'])) { $bundlerName = $this->package['extra']['phar']['bundler']; } if ($bundlerName === 'composer') { return new ExplicitBundler($this, $logger); } elseif ($bundlerName === 'complete') { return new CompleteBundler($this, $logger); } else { $logger->log('Invalid bundler "' . $bundlerName . '" specified in package "' . $this->getName() . '", will fall back to "complete" bundler'); return new CompleteBundler($this, $logger); } }
[ "public", "function", "getBundler", "(", "Logger", "$", "logger", ")", "{", "$", "bundlerName", "=", "'complete'", ";", "if", "(", "isset", "(", "$", "this", "->", "package", "[", "'extra'", "]", "[", "'phar'", "]", "[", "'bundler'", "]", ")", ")", "...
Get Bundler instance to bundle this package @param Logger $logger @return BundlerInterface
[ "Get", "Bundler", "instance", "to", "bundle", "this", "package" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Package.php#L78-L93
clue/phar-composer
src/Clue/PharComposer/Package/Package.php
Package.getBins
public function getBins() { if (!isset($this->package['bin'])) { return array(); } $bins = array(); foreach ($this->package['bin'] as $bin) { $bins []= $this->getAbsolutePath($bin); } return $bins; }
php
public function getBins() { if (!isset($this->package['bin'])) { return array(); } $bins = array(); foreach ($this->package['bin'] as $bin) { $bins []= $this->getAbsolutePath($bin); } return $bins; }
[ "public", "function", "getBins", "(", ")", "{", "if", "(", "!", "isset", "(", "$", "this", "->", "package", "[", "'bin'", "]", ")", ")", "{", "return", "array", "(", ")", ";", "}", "$", "bins", "=", "array", "(", ")", ";", "foreach", "(", "$", ...
Get list of files defined as "bin" (absolute paths) @return string[]
[ "Get", "list", "of", "files", "defined", "as", "bin", "(", "absolute", "paths", ")" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Package.php#L112-L124
clue/phar-composer
src/Clue/PharComposer/Package/Package.php
Package.getBlacklistFilter
public function getBlacklistFilter() { $blacklist = $this->getBlacklist(); return function (SplFileInfo $file) use ($blacklist) { return in_array($file->getPathname(), $blacklist) ? false : null; }; }
php
public function getBlacklistFilter() { $blacklist = $this->getBlacklist(); return function (SplFileInfo $file) use ($blacklist) { return in_array($file->getPathname(), $blacklist) ? false : null; }; }
[ "public", "function", "getBlacklistFilter", "(", ")", "{", "$", "blacklist", "=", "$", "this", "->", "getBlacklist", "(", ")", ";", "return", "function", "(", "SplFileInfo", "$", "file", ")", "use", "(", "$", "blacklist", ")", "{", "return", "in_array", ...
Gets a filter function to exclude blacklisted files Only used for CompleteBundler at the moment @return Closure @uses self::getBlacklist()
[ "Gets", "a", "filter", "function", "to", "exclude", "blacklisted", "files" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Package.php#L149-L156
clue/phar-composer
src/Clue/PharComposer/App.php
App.getCommandName
protected function getCommandName(InputInterface $input) { if ($input->getFirstArgument() === null && !$input->hasParameterOption(array('--help', '-h'))) { $this->isDefault = true; return $this->getDefaultCommandName(); } return parent::getCommandName($input); }
php
protected function getCommandName(InputInterface $input) { if ($input->getFirstArgument() === null && !$input->hasParameterOption(array('--help', '-h'))) { $this->isDefault = true; return $this->getDefaultCommandName(); } return parent::getCommandName($input); }
[ "protected", "function", "getCommandName", "(", "InputInterface", "$", "input", ")", "{", "if", "(", "$", "input", "->", "getFirstArgument", "(", ")", "===", "null", "&&", "!", "$", "input", "->", "hasParameterOption", "(", "array", "(", "'--help'", ",", "...
Gets the name of the command based on input. @param InputInterface $input The input interface @return string The command name
[ "Gets", "the", "name", "of", "the", "command", "based", "on", "input", "." ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/App.php#L31-L38
clue/phar-composer
src/Clue/PharComposer/Phar/Packager.php
Packager.coerceWritable
public function coerceWritable($wait = 1) { try { $this->assertWritable(); } catch (UnexpectedValueException $e) { if (!function_exists('pcntl_exec')) { $this->log('<error>' . $e->getMessage() . '</error>'); return; } $this->log('<info>' . $e->getMessage() . ', trying to re-spawn with correct config</info>'); if ($wait) { sleep($wait); } $args = array_merge(array('php', '-d phar.readonly=off'), $_SERVER['argv']); if (pcntl_exec('/usr/bin/env', $args) === false) { $this->log('<error>Unable to switch into new configuration</error>'); return; } } }
php
public function coerceWritable($wait = 1) { try { $this->assertWritable(); } catch (UnexpectedValueException $e) { if (!function_exists('pcntl_exec')) { $this->log('<error>' . $e->getMessage() . '</error>'); return; } $this->log('<info>' . $e->getMessage() . ', trying to re-spawn with correct config</info>'); if ($wait) { sleep($wait); } $args = array_merge(array('php', '-d phar.readonly=off'), $_SERVER['argv']); if (pcntl_exec('/usr/bin/env', $args) === false) { $this->log('<error>Unable to switch into new configuration</error>'); return; } } }
[ "public", "function", "coerceWritable", "(", "$", "wait", "=", "1", ")", "{", "try", "{", "$", "this", "->", "assertWritable", "(", ")", ";", "}", "catch", "(", "UnexpectedValueException", "$", "e", ")", "{", "if", "(", "!", "function_exists", "(", "'p...
ensure writing phar files is enabled or respawn with PHP setting which allows writing @param int $wait @return void @uses assertWritable()
[ "ensure", "writing", "phar", "files", "is", "enabled", "or", "respawn", "with", "PHP", "setting", "which", "allows", "writing" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Phar/Packager.php#L58-L80
clue/phar-composer
src/Clue/PharComposer/Package/Bundler/Complete.php
Complete.bundle
public function bundle() { $bundle = new Bundle(); $iterator = Finder::create() ->files() ->ignoreVCS(true) ->filter($this->package->getBlacklistFilter()) ->exclude($this->package->getPathVendorRelative()) ->in($this->package->getDirectory()); $this->logger->log(' Adding whole project directory "' . $this->package->getDirectory() . '"'); return $bundle->addDir($iterator); }
php
public function bundle() { $bundle = new Bundle(); $iterator = Finder::create() ->files() ->ignoreVCS(true) ->filter($this->package->getBlacklistFilter()) ->exclude($this->package->getPathVendorRelative()) ->in($this->package->getDirectory()); $this->logger->log(' Adding whole project directory "' . $this->package->getDirectory() . '"'); return $bundle->addDir($iterator); }
[ "public", "function", "bundle", "(", ")", "{", "$", "bundle", "=", "new", "Bundle", "(", ")", ";", "$", "iterator", "=", "Finder", "::", "create", "(", ")", "->", "files", "(", ")", "->", "ignoreVCS", "(", "true", ")", "->", "filter", "(", "$", "...
returns a bundle @return Bundle
[ "returns", "a", "bundle" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Bundler/Complete.php#L38-L49
clue/phar-composer
src/Clue/PharComposer/Phar/TargetPhar.php
TargetPhar.addBundle
public function addBundle(Bundle $bundle) { foreach ($bundle as $resource) { if (is_string($resource)) { $this->addFile($resource); } else { $this->buildFromIterator($resource); } } }
php
public function addBundle(Bundle $bundle) { foreach ($bundle as $resource) { if (is_string($resource)) { $this->addFile($resource); } else { $this->buildFromIterator($resource); } } }
[ "public", "function", "addBundle", "(", "Bundle", "$", "bundle", ")", "{", "foreach", "(", "$", "bundle", "as", "$", "resource", ")", "{", "if", "(", "is_string", "(", "$", "resource", ")", ")", "{", "$", "this", "->", "addFile", "(", "$", "resource"...
adds given list of resources to phar @param Bundle $bundle
[ "adds", "given", "list", "of", "resources", "to", "phar" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Phar/TargetPhar.php#L65-L74
clue/phar-composer
src/Clue/PharComposer/Phar/TargetPhar.php
TargetPhar.addFile
public function addFile($file) { $this->box->addFile($file, $this->pharComposer->getPathLocalToBase($file)); }
php
public function addFile($file) { $this->box->addFile($file, $this->pharComposer->getPathLocalToBase($file)); }
[ "public", "function", "addFile", "(", "$", "file", ")", "{", "$", "this", "->", "box", "->", "addFile", "(", "$", "file", ",", "$", "this", "->", "pharComposer", "->", "getPathLocalToBase", "(", "$", "file", ")", ")", ";", "}" ]
Adds a file to the Phar, after compacting it and replacing its placeholders. @param string $file The file name.
[ "Adds", "a", "file", "to", "the", "Phar", "after", "compacting", "it", "and", "replacing", "its", "placeholders", "." ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Phar/TargetPhar.php#L82-L85
clue/phar-composer
src/Clue/PharComposer/Phar/TargetPhar.php
TargetPhar.buildFromIterator
public function buildFromIterator(Traversable $iterator) { $this->box->buildFromIterator($iterator, $this->pharComposer->getBase()); }
php
public function buildFromIterator(Traversable $iterator) { $this->box->buildFromIterator($iterator, $this->pharComposer->getBase()); }
[ "public", "function", "buildFromIterator", "(", "Traversable", "$", "iterator", ")", "{", "$", "this", "->", "box", "->", "buildFromIterator", "(", "$", "iterator", ",", "$", "this", "->", "pharComposer", "->", "getBase", "(", ")", ")", ";", "}" ]
Similar to Phar::buildFromIterator(), except the files will be compacted and their placeholders replaced. @param Traversable $iterator The iterator.
[ "Similar", "to", "Phar", "::", "buildFromIterator", "()", "except", "the", "files", "will", "be", "compacted", "and", "their", "placeholders", "replaced", "." ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Phar/TargetPhar.php#L93-L96
clue/phar-composer
src/Clue/PharComposer/Package/Bundle.php
Bundle.contains
public function contains($resource) { foreach ($this->resources as $containedResource) { if (is_string($containedResource) && $containedResource == $resource) { return true; } if ($containedResource instanceof Finder && $this->directoryContains($containedResource, $resource)) { return true; } } return false; }
php
public function contains($resource) { foreach ($this->resources as $containedResource) { if (is_string($containedResource) && $containedResource == $resource) { return true; } if ($containedResource instanceof Finder && $this->directoryContains($containedResource, $resource)) { return true; } } return false; }
[ "public", "function", "contains", "(", "$", "resource", ")", "{", "foreach", "(", "$", "this", "->", "resources", "as", "$", "containedResource", ")", "{", "if", "(", "is_string", "(", "$", "containedResource", ")", "&&", "$", "containedResource", "==", "$...
checks if a bundle contains given resource @param string $resource @return bool
[ "checks", "if", "a", "bundle", "contains", "given", "resource" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Bundle.php#L63-L76
clue/phar-composer
src/Clue/PharComposer/Package/Bundle.php
Bundle.directoryContains
private function directoryContains(Finder $dir, $resource) { foreach ($dir as $containedResource) { /* @var $containedResource \SplFileInfo */ if (substr($containedResource->getRealPath(), 0, strlen($resource)) == $resource) { return true; } } return false; }
php
private function directoryContains(Finder $dir, $resource) { foreach ($dir as $containedResource) { /* @var $containedResource \SplFileInfo */ if (substr($containedResource->getRealPath(), 0, strlen($resource)) == $resource) { return true; } } return false; }
[ "private", "function", "directoryContains", "(", "Finder", "$", "dir", ",", "$", "resource", ")", "{", "foreach", "(", "$", "dir", "as", "$", "containedResource", ")", "{", "/* @var $containedResource \\SplFileInfo */", "if", "(", "substr", "(", "$", "containedR...
checks if given directory contains given resource @param Finder $dir @param string $resource @return bool
[ "checks", "if", "given", "directory", "contains", "given", "resource" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Bundle.php#L85-L95
clue/phar-composer
src/Clue/PharComposer/Package/Bundler/Explicit.php
Explicit.bundle
public function bundle() { $bundle = new Bundle(); $this->bundleBins($bundle); $autoload = $this->package->getAutoload(); $this->bundlePsr0($bundle, $autoload); $this->bundleClassmap($bundle, $autoload); $this->bundleFiles($bundle, $autoload); return $bundle; }
php
public function bundle() { $bundle = new Bundle(); $this->bundleBins($bundle); $autoload = $this->package->getAutoload(); $this->bundlePsr0($bundle, $autoload); $this->bundleClassmap($bundle, $autoload); $this->bundleFiles($bundle, $autoload); return $bundle; }
[ "public", "function", "bundle", "(", ")", "{", "$", "bundle", "=", "new", "Bundle", "(", ")", ";", "$", "this", "->", "bundleBins", "(", "$", "bundle", ")", ";", "$", "autoload", "=", "$", "this", "->", "package", "->", "getAutoload", "(", ")", ";"...
returns a bundle @return Bundle
[ "returns", "a", "bundle" ]
train
https://github.com/clue/phar-composer/blob/3ea2cd961c45290b2578c6bf971ae028bfcd6377/src/Clue/PharComposer/Package/Bundler/Explicit.php#L39-L50
Gernott/mask
Classes/CodeGenerator/TcaCodeGenerator.php
TcaCodeGenerator.setInlineTca
public function setInlineTca($json) { // Generate TCA for IRRE Fields and Tables $notIrreTables = array("pages", "tt_content", "sys_file_reference"); if ($json) { foreach ($json as $table => $subJson) { $fieldTCA = array(); if (array_search($table, $notIrreTables) === false) { // Generate Table TCA $this->generateTableTca($table, $subJson["tca"]); // Generate Field TCA $fieldTCA = $this->generateFieldsTca($subJson["tca"]); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns($table, $fieldTCA); // set label for inline if (!empty($json["tt_content"]["tca"][$table]["inlineLabel"])) { $fields = array_keys($subJson["tca"]); if (array_search($json["tt_content"]["tca"][$table]["inlineLabel"], $fields) !== false) { $GLOBALS["TCA"][$table]["ctrl"]['label'] = $json["tt_content"]["tca"][$table]["inlineLabel"]; } } // set icon for inline if (!empty($json["tt_content"]["tca"][$table]["inlineIcon"])) { $GLOBALS["TCA"][$table]["ctrl"]['iconfile'] = $json["tt_content"]["tca"][$table]["inlineIcon"]; } else { $GLOBALS["TCA"][$table]["ctrl"]['iconfile'] = "EXT:mask/Resources/Public/Icons/Extension.svg"; } // hide table in list view $GLOBALS["TCA"][$table]['ctrl']['hideTable'] = true; } } } }
php
public function setInlineTca($json) { // Generate TCA for IRRE Fields and Tables $notIrreTables = array("pages", "tt_content", "sys_file_reference"); if ($json) { foreach ($json as $table => $subJson) { $fieldTCA = array(); if (array_search($table, $notIrreTables) === false) { // Generate Table TCA $this->generateTableTca($table, $subJson["tca"]); // Generate Field TCA $fieldTCA = $this->generateFieldsTca($subJson["tca"]); \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addTCAcolumns($table, $fieldTCA); // set label for inline if (!empty($json["tt_content"]["tca"][$table]["inlineLabel"])) { $fields = array_keys($subJson["tca"]); if (array_search($json["tt_content"]["tca"][$table]["inlineLabel"], $fields) !== false) { $GLOBALS["TCA"][$table]["ctrl"]['label'] = $json["tt_content"]["tca"][$table]["inlineLabel"]; } } // set icon for inline if (!empty($json["tt_content"]["tca"][$table]["inlineIcon"])) { $GLOBALS["TCA"][$table]["ctrl"]['iconfile'] = $json["tt_content"]["tca"][$table]["inlineIcon"]; } else { $GLOBALS["TCA"][$table]["ctrl"]['iconfile'] = "EXT:mask/Resources/Public/Icons/Extension.svg"; } // hide table in list view $GLOBALS["TCA"][$table]['ctrl']['hideTable'] = true; } } } }
[ "public", "function", "setInlineTca", "(", "$", "json", ")", "{", "// Generate TCA for IRRE Fields and Tables", "$", "notIrreTables", "=", "array", "(", "\"pages\"", ",", "\"tt_content\"", ",", "\"sys_file_reference\"", ")", ";", "if", "(", "$", "json", ")", "{", ...
Generates and sets the correct tca for all the inline fields @author Benjamin Butschell <bb@webprofil.at> @param array $json
[ "Generates", "and", "sets", "the", "correct", "tca", "for", "all", "the", "inline", "fields" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TcaCodeGenerator.php#L40-L73
Gernott/mask
Classes/CodeGenerator/TcaCodeGenerator.php
TcaCodeGenerator.setElementsTca
public function setElementsTca($tca) { $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $defaultTabs = ",--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.appearanceLinks;appearanceLinks,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,--palette--;;language,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,--palette--;;hidden,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,categories,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,rowDescription,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended"; // add gridelements fields, to make mask work with gridelements out of the box $gridelements = ''; if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('gridelements')) { $gridelements = ', tx_gridelements_container, tx_gridelements_columns'; } if ($tca) { // add new group in CType selectbox $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][] = [ 'LLL:EXT:mask/Resources/Private/Language/locallang_mask.xlf:new_content_element_tab', '--div--' ]; foreach ($tca as $elementvalue) { if (!$elementvalue["hidden"]) { $prependTabs = "--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,"; $fieldArray = array(); $label = $elementvalue["shortLabel"] ? $elementvalue["shortLabel"] : $elementvalue["label"]; // Optional shortLabel // add new entry in CType selectbox \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(array( $label, "mask_" . $elementvalue["key"], 'mask-ce-' . $elementvalue["key"] ), "CType", "mask"); // add all the fields that should be shown if (is_array($elementvalue["columns"])) { foreach ($elementvalue["columns"] as $index => $fieldKey) { // check if this field is of type tab $formType = $fieldHelper->getFormType($fieldKey, $elementvalue["key"], "tt_content"); if ($formType == "Tab") { $label = $fieldHelper->getLabel($elementvalue["key"], $fieldKey, "tt_content"); // if a tab is in the first position then change the name of the general tab if ($index === 0) { $prependTabs = '--div--;' . $label . "," . $prependTabs; } else { // otherwise just add new tab $fieldArray[] = '--div--;' . $label; } } else { $fieldArray[] = $fieldKey; } } } $fields = implode(",", $fieldArray); $GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes']["mask_" . $elementvalue["key"]] = 'mask-ce-' . $elementvalue["key"]; $GLOBALS['TCA']["tt_content"]["types"]["mask_" . $elementvalue["key"]]["columnsOverrides"]["bodytext"]["config"]['richtextConfiguration'] = 'default'; $GLOBALS['TCA']["tt_content"]["types"]["mask_" . $elementvalue["key"]]["columnsOverrides"]["bodytext"]["config"]['enableRichtext'] = 1; $GLOBALS['TCA']["tt_content"]["types"]["mask_" . $elementvalue["key"]]["showitem"] = $prependTabs . $fields . $defaultTabs . $gridelements; } } } }
php
public function setElementsTca($tca) { $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $defaultTabs = ",--div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.appearance,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.frames;frames,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.appearanceLinks;appearanceLinks,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:language,--palette--;;language,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:access,--palette--;;hidden,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.access;access,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:categories,--div--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_category.tabs.category,categories,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:notes,rowDescription,--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:extended"; // add gridelements fields, to make mask work with gridelements out of the box $gridelements = ''; if (\TYPO3\CMS\Core\Utility\ExtensionManagementUtility::isLoaded('gridelements')) { $gridelements = ', tx_gridelements_container, tx_gridelements_columns'; } if ($tca) { // add new group in CType selectbox $GLOBALS['TCA']['tt_content']['columns']['CType']['config']['items'][] = [ 'LLL:EXT:mask/Resources/Private/Language/locallang_mask.xlf:new_content_element_tab', '--div--' ]; foreach ($tca as $elementvalue) { if (!$elementvalue["hidden"]) { $prependTabs = "--div--;LLL:EXT:core/Resources/Private/Language/Form/locallang_tabs.xlf:general,--palette--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:palette.general;general,"; $fieldArray = array(); $label = $elementvalue["shortLabel"] ? $elementvalue["shortLabel"] : $elementvalue["label"]; // Optional shortLabel // add new entry in CType selectbox \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addPlugin(array( $label, "mask_" . $elementvalue["key"], 'mask-ce-' . $elementvalue["key"] ), "CType", "mask"); // add all the fields that should be shown if (is_array($elementvalue["columns"])) { foreach ($elementvalue["columns"] as $index => $fieldKey) { // check if this field is of type tab $formType = $fieldHelper->getFormType($fieldKey, $elementvalue["key"], "tt_content"); if ($formType == "Tab") { $label = $fieldHelper->getLabel($elementvalue["key"], $fieldKey, "tt_content"); // if a tab is in the first position then change the name of the general tab if ($index === 0) { $prependTabs = '--div--;' . $label . "," . $prependTabs; } else { // otherwise just add new tab $fieldArray[] = '--div--;' . $label; } } else { $fieldArray[] = $fieldKey; } } } $fields = implode(",", $fieldArray); $GLOBALS['TCA']['tt_content']['ctrl']['typeicon_classes']["mask_" . $elementvalue["key"]] = 'mask-ce-' . $elementvalue["key"]; $GLOBALS['TCA']["tt_content"]["types"]["mask_" . $elementvalue["key"]]["columnsOverrides"]["bodytext"]["config"]['richtextConfiguration'] = 'default'; $GLOBALS['TCA']["tt_content"]["types"]["mask_" . $elementvalue["key"]]["columnsOverrides"]["bodytext"]["config"]['enableRichtext'] = 1; $GLOBALS['TCA']["tt_content"]["types"]["mask_" . $elementvalue["key"]]["showitem"] = $prependTabs . $fields . $defaultTabs . $gridelements; } } } }
[ "public", "function", "setElementsTca", "(", "$", "tca", ")", "{", "$", "fieldHelper", "=", "\\", "TYPO3", "\\", "CMS", "\\", "Core", "\\", "Utility", "\\", "GeneralUtility", "::", "makeInstance", "(", "'MASK\\\\Mask\\\\Helper\\\\FieldHelper'", ")", ";", "$", ...
Generates and sets the tca for all the content-elements @param array $tca @author Benjamin Butschell <bb@webprofil.at>
[ "Generates", "and", "sets", "the", "tca", "for", "all", "the", "content", "-", "elements" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TcaCodeGenerator.php#L81-L143
Gernott/mask
Classes/CodeGenerator/TcaCodeGenerator.php
TcaCodeGenerator.setPageTca
public function setPageTca($tca) { $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $prependTabs = "--div--;Content-Fields,"; if ($tca) { $i = 0; foreach ($tca as $fieldKey => $config) { // no information about which element this field is for at this point $elements = $fieldHelper->getElementsWhichUseField($fieldKey, "pages"); $element = $elements[0]; // check if this field is of type tab $formType = $fieldHelper->getFormType($fieldKey, $element["key"], "pages"); if ($formType == "Tab") { $label = $fieldHelper->getLabel($element["key"], $fieldKey, "pages"); // if a tab is in the first position then change the name of the general tab if ($i === 0) { $prependTabs = '--div--;' . $label . ","; } else { // otherwise just add new tab $fieldArray[] = '--div--;' . $label; } } else { $fieldArray[] = $fieldKey; } $i++; } } if (!empty($fieldArray)) { $pageFieldString = $prependTabs . implode(",", $fieldArray); } else { $pageFieldString = $prependTabs; } \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', $pageFieldString); }
php
public function setPageTca($tca) { $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $prependTabs = "--div--;Content-Fields,"; if ($tca) { $i = 0; foreach ($tca as $fieldKey => $config) { // no information about which element this field is for at this point $elements = $fieldHelper->getElementsWhichUseField($fieldKey, "pages"); $element = $elements[0]; // check if this field is of type tab $formType = $fieldHelper->getFormType($fieldKey, $element["key"], "pages"); if ($formType == "Tab") { $label = $fieldHelper->getLabel($element["key"], $fieldKey, "pages"); // if a tab is in the first position then change the name of the general tab if ($i === 0) { $prependTabs = '--div--;' . $label . ","; } else { // otherwise just add new tab $fieldArray[] = '--div--;' . $label; } } else { $fieldArray[] = $fieldKey; } $i++; } } if (!empty($fieldArray)) { $pageFieldString = $prependTabs . implode(",", $fieldArray); } else { $pageFieldString = $prependTabs; } \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::addToAllTCAtypes('pages', $pageFieldString); }
[ "public", "function", "setPageTca", "(", "$", "tca", ")", "{", "$", "fieldHelper", "=", "\\", "TYPO3", "\\", "CMS", "\\", "Core", "\\", "Utility", "\\", "GeneralUtility", "::", "makeInstance", "(", "'MASK\\\\Mask\\\\Helper\\\\FieldHelper'", ")", ";", "$", "pre...
Generates and sets the tca for all the extended pages @param array $tca @author Benjamin Butschell <bb@webprofil.at>
[ "Generates", "and", "sets", "the", "tca", "for", "all", "the", "extended", "pages" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TcaCodeGenerator.php#L151-L187
Gernott/mask
Classes/CodeGenerator/TcaCodeGenerator.php
TcaCodeGenerator.generateFieldsTca
public function generateFieldsTca($tca) { $generalUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Utility\\GeneralUtility'); $columns = array(); if ($tca) { foreach ($tca as $tcakey => $tcavalue) { $addToTca = true; if ($tcavalue) { foreach ($tcavalue as $fieldkey => $fieldvalue) { // Add File-Config for file-field if ($fieldkey == "options" && $fieldvalue == "file") { $fieldName = $tcakey; $customSettingOverride = array( 'overrideChildTca' => array( 'types' => array( '0' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '1' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '2' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '3' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '4' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '5' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), ), ) ); $customSettingOverride["appearance"] = $tcavalue["config"]["appearance"]; if ($customSettingOverride["appearance"]["fileUploadAllowed"] == "") { $customSettingOverride["appearance"]["fileUploadAllowed"] = false; } if ($customSettingOverride["appearance"]["useSortable"] == "") { $customSettingOverride["appearance"]["useSortable"] = 0; } else { $customSettingOverride["appearance"]["useSortable"] = 1; } if ($tcavalue["config"]["filter"]["0"]["parameters"]["allowedFileExtensions"] != "") { $allowedFileExtensions = $tcavalue["config"]["filter"]["0"]["parameters"]["allowedFileExtensions"]; } else { $allowedFileExtensions = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']; } $columns[$tcakey]["config"] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig($fieldName, $customSettingOverride, $allowedFileExtensions); } // check if field is actually a tab if (isset($fieldvalue["type"]) && $fieldvalue["type"] == "tab") { $addToTca = false; } // Fill missing tablename in TCA-Config for inline-fields if ($fieldkey == "config" && $tcavalue[$fieldkey]["foreign_table"] == "--inlinetable--") { $tcavalue[$fieldkey]["foreign_table"] = $tcakey; } // set date ranges if date or datetime field if ($fieldkey == "config" && ($tcavalue[$fieldkey]["dbType"] == "date" || $tcavalue[$fieldkey]["dbType"] == "datetime")) { if ($tcavalue[$fieldkey]["range"]["upper"] != "") { $date = new \DateTime($tcavalue[$fieldkey]["range"]["upper"]); $tcavalue[$fieldkey]["range"]["upper"] = $date->getTimestamp() + 86400; } if ($tcavalue[$fieldkey]["range"]["lower"] != "") { $date = new \DateTime($tcavalue[$fieldkey]["range"]["lower"]); $tcavalue[$fieldkey]["range"]["lower"] = $date->getTimestamp() + 86400; } } // set correct rendertype if format (code highlighting) is set in text tca if ($fieldkey == "config" && $tcavalue[$fieldkey]["format"] != "") { $tcavalue[$fieldkey]["renderType"] = "t3editor"; } // make some adjustmens to content fields if ( $fieldkey == "config" && $tcavalue[$fieldkey]["foreign_table"] == "tt_content" && $tcavalue[$fieldkey]["type"] == "inline" ) { $tcavalue[$fieldkey]["foreign_field"] = $tcakey . "_parent"; if ($tcavalue["cTypes"]) { $tcavalue[$fieldkey]["overrideChildTca"]["columns"]["CType"]["config"]["default"] = reset($tcavalue["cTypes"]); } } // merge user inputs with file array if (!is_array($columns[$tcakey])) { $columns[$tcakey] = array(); } else { \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($columns[$tcakey], $tcavalue); } // Unset some values that are not needed in TCA unset($columns[$tcakey]["options"]); unset($columns[$tcakey]["key"]); unset($columns[$tcakey]["rte"]); unset($columns[$tcakey]["inlineParent"]); unset($columns[$tcakey]["inlineLabel"]); unset($columns[$tcakey]["inlineIcon"]); unset($columns[$tcakey]["cTypes"]); // $GLOBALS['TCA']["tt_content"]["types"]["mask_asdfsdaf"]["columnsOverrides"]["tx_mask_".$tcakey]["config"]['enableRichtext'] = 1; // $GLOBALS['TCA']["tt_content"]["types"]["mask_asdfsdaf"]["columnsOverrides"]["tx_mask_".$tcakey]["config"]['richtextConfiguration'] = 'default'; $columns[$tcakey] = $generalUtility->removeBlankOptions($columns[$tcakey]); $columns[$tcakey] = $generalUtility->replaceKey($columns[$tcakey], $tcakey); } } // if this field should not be added to the tca (e.g. tabs) if (!$addToTca) { unset($columns[$tcakey]); } } } return $columns; }
php
public function generateFieldsTca($tca) { $generalUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Utility\\GeneralUtility'); $columns = array(); if ($tca) { foreach ($tca as $tcakey => $tcavalue) { $addToTca = true; if ($tcavalue) { foreach ($tcavalue as $fieldkey => $fieldvalue) { // Add File-Config for file-field if ($fieldkey == "options" && $fieldvalue == "file") { $fieldName = $tcakey; $customSettingOverride = array( 'overrideChildTca' => array( 'types' => array( '0' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '1' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '2' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '3' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '4' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), '5' => array( 'showitem' => '--palette--;LLL:EXT:core/Resources/Private/Language/locallang_tca.xlf:sys_file_reference.imageoverlayPalette;imageoverlayPalette, --palette--;;filePalette', ), ), ) ); $customSettingOverride["appearance"] = $tcavalue["config"]["appearance"]; if ($customSettingOverride["appearance"]["fileUploadAllowed"] == "") { $customSettingOverride["appearance"]["fileUploadAllowed"] = false; } if ($customSettingOverride["appearance"]["useSortable"] == "") { $customSettingOverride["appearance"]["useSortable"] = 0; } else { $customSettingOverride["appearance"]["useSortable"] = 1; } if ($tcavalue["config"]["filter"]["0"]["parameters"]["allowedFileExtensions"] != "") { $allowedFileExtensions = $tcavalue["config"]["filter"]["0"]["parameters"]["allowedFileExtensions"]; } else { $allowedFileExtensions = $GLOBALS['TYPO3_CONF_VARS']['GFX']['imagefile_ext']; } $columns[$tcakey]["config"] = \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::getFileFieldTCAConfig($fieldName, $customSettingOverride, $allowedFileExtensions); } // check if field is actually a tab if (isset($fieldvalue["type"]) && $fieldvalue["type"] == "tab") { $addToTca = false; } // Fill missing tablename in TCA-Config for inline-fields if ($fieldkey == "config" && $tcavalue[$fieldkey]["foreign_table"] == "--inlinetable--") { $tcavalue[$fieldkey]["foreign_table"] = $tcakey; } // set date ranges if date or datetime field if ($fieldkey == "config" && ($tcavalue[$fieldkey]["dbType"] == "date" || $tcavalue[$fieldkey]["dbType"] == "datetime")) { if ($tcavalue[$fieldkey]["range"]["upper"] != "") { $date = new \DateTime($tcavalue[$fieldkey]["range"]["upper"]); $tcavalue[$fieldkey]["range"]["upper"] = $date->getTimestamp() + 86400; } if ($tcavalue[$fieldkey]["range"]["lower"] != "") { $date = new \DateTime($tcavalue[$fieldkey]["range"]["lower"]); $tcavalue[$fieldkey]["range"]["lower"] = $date->getTimestamp() + 86400; } } // set correct rendertype if format (code highlighting) is set in text tca if ($fieldkey == "config" && $tcavalue[$fieldkey]["format"] != "") { $tcavalue[$fieldkey]["renderType"] = "t3editor"; } // make some adjustmens to content fields if ( $fieldkey == "config" && $tcavalue[$fieldkey]["foreign_table"] == "tt_content" && $tcavalue[$fieldkey]["type"] == "inline" ) { $tcavalue[$fieldkey]["foreign_field"] = $tcakey . "_parent"; if ($tcavalue["cTypes"]) { $tcavalue[$fieldkey]["overrideChildTca"]["columns"]["CType"]["config"]["default"] = reset($tcavalue["cTypes"]); } } // merge user inputs with file array if (!is_array($columns[$tcakey])) { $columns[$tcakey] = array(); } else { \TYPO3\CMS\Core\Utility\ArrayUtility::mergeRecursiveWithOverrule($columns[$tcakey], $tcavalue); } // Unset some values that are not needed in TCA unset($columns[$tcakey]["options"]); unset($columns[$tcakey]["key"]); unset($columns[$tcakey]["rte"]); unset($columns[$tcakey]["inlineParent"]); unset($columns[$tcakey]["inlineLabel"]); unset($columns[$tcakey]["inlineIcon"]); unset($columns[$tcakey]["cTypes"]); // $GLOBALS['TCA']["tt_content"]["types"]["mask_asdfsdaf"]["columnsOverrides"]["tx_mask_".$tcakey]["config"]['enableRichtext'] = 1; // $GLOBALS['TCA']["tt_content"]["types"]["mask_asdfsdaf"]["columnsOverrides"]["tx_mask_".$tcakey]["config"]['richtextConfiguration'] = 'default'; $columns[$tcakey] = $generalUtility->removeBlankOptions($columns[$tcakey]); $columns[$tcakey] = $generalUtility->replaceKey($columns[$tcakey], $tcakey); } } // if this field should not be added to the tca (e.g. tabs) if (!$addToTca) { unset($columns[$tcakey]); } } } return $columns; }
[ "public", "function", "generateFieldsTca", "(", "$", "tca", ")", "{", "$", "generalUtility", "=", "\\", "TYPO3", "\\", "CMS", "\\", "Core", "\\", "Utility", "\\", "GeneralUtility", "::", "makeInstance", "(", "'MASK\\\\Mask\\\\Utility\\\\GeneralUtility'", ")", ";",...
Generates the TCA for fields @param array $tca @return string
[ "Generates", "the", "TCA", "for", "fields" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TcaCodeGenerator.php#L195-L322
Gernott/mask
Classes/CodeGenerator/TcaCodeGenerator.php
TcaCodeGenerator.generateTableTca
public function generateTableTca($table, $tca) { $tcaTemplate = array( 'ctrl' => array( 'title' => 'IRRE-Table', 'label' => 'uid', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => true, 'versioningWS' => true, 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'enablecolumns' => array( 'disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime', ), 'searchFields' => '', 'dynamicConfigFile' => '', 'iconfile' => '' ), 'interface' => array( 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, ', ), 'types' => array( '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, starttime, endtime'), ), 'palettes' => array( '1' => array('showitem' => ''), ), 'columns' => array( 'sys_language_uid' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => array( 'type' => 'select', 'renderType' => 'selectSingle', 'items' => array( array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1, 'flags-multiple'), ), 'special' => 'languages', 'default' => 0 ), ), 'l10n_parent' => array( 'displayCond' => 'FIELD:sys_language_uid:>:0', 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent', 'config' => array( 'type' => 'select', 'renderType' => 'selectSingle', 'items' => array( array('', 0), ), 'foreign_table' => 'tx_test_domain_model_murph', 'foreign_table_where' => 'AND tx_test_domain_model_murph.pid=###CURRENT_PID### AND tx_test_domain_model_murph.sys_language_uid IN (-1,0)', 'default' => 0, ), ), 'l10n_diffsource' => array( 'config' => array( 'type' => 'passthrough', ), ), 't3ver_label' => array( 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel', 'config' => array( 'type' => 'input', 'size' => 30, 'max' => 255, ) ), 'hidden' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', 'config' => array( 'type' => 'check', ), ), 'starttime' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime', 'config' => array( 'behaviour' => array( 'allowLanguageSynchronization' => true ), 'renderType' => 'inputDateTime', 'type' => 'input', 'size' => 13, 'eval' => 'datetime,int', 'checkbox' => 0, 'default' => 0 ), ), 'endtime' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime', 'config' => array( 'behaviour' => array( 'allowLanguageSynchronization' => true ), 'renderType' => 'inputDateTime', 'type' => 'input', 'size' => 13, 'eval' => 'datetime,int', 'checkbox' => 0, 'default' => 0 ), ), 'parentid' => array( 'config' => array( 'type' => 'select', 'renderType' => 'selectSingle', 'items' => array( array('', 0), ), 'foreign_table' => 'tt_content', 'foreign_table_where' => 'AND tt_content.pid=###CURRENT_PID### AND tt_content.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)', ), ), 'parenttable' => array( 'config' => array( 'type' => 'passthrough', ), ), 'sorting' => array( 'config' => array( 'type' => 'passthrough', ), ), ), ); $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $generalUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Utility\\GeneralUtility'); // now add all the fields that should be shown $prependTabs = "sys_language_uid, l10n_parent, l10n_diffsource, hidden, "; if ($tca) { $i = 0; uasort($tca, function ($columnA, $columnB) { $a = isset($columnA['order']) ? (int)$columnA['order'] : 0; $b = isset($columnB['order']) ? (int)$columnB['order'] : 0; return $a - $b; }); foreach ($tca as $fieldKey => $configuration) { // check if this field is of type tab $formType = $fieldHelper->getFormType($fieldKey, "", $table); if ($formType == "Tab") { $label = $configuration["label"]; // if a tab is in the first position then change the name of the general tab if ($i === 0) { $prependTabs = '--div--;' . $label . "," . $prependTabs; } else { // otherwise just add new tab $fields[] = '--div--;' . $label; } } else { $fields[] = $fieldKey; } $i++; } } // take first field for inline label if (!empty($fields)) { $labelField = $generalUtility->getFirstNoneTabField($fields); } // get parent table of this inline table $parentTable = $fieldHelper->getFieldType($table); // Adjust TCA-Template $tableTca = $tcaTemplate; $tableTca["ctrl"]["title"] = $table; $tableTca["ctrl"]["label"] = $labelField; $tableTca["ctrl"]["searchFields"] = implode(",", (array)$fields); $tableTca["interface"]["showRecordFieldList"] = "sys_language_uid, l10n_parent, l10n_diffsource, hidden, " . implode(", ", (array)$fields); $tableTca["types"]["1"]["showitem"] = $prependTabs . implode(", ", (array)$fields) . ", --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime"; $tableTca["columns"]["l10n_parent"]["config"]["foreign_table"] = $table; $tableTca["columns"]["l10n_parent"]["config"]["foreign_table_where"] = 'AND ' . $table . '.pid=###CURRENT_PID### AND ' . $table . '.sys_language_uid IN (-1,0)'; $tableTca["columns"]["parentid"]["config"]["foreign_table"] = $parentTable; $tableTca["columns"]["parentid"]["config"]["foreign_table_where"] = 'AND ' . $parentTable . '.pid=###CURRENT_PID### AND ' . $parentTable . '.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)'; // Add some stuff we need to make irre work like it should $GLOBALS["TCA"][$table] = $tableTca; }
php
public function generateTableTca($table, $tca) { $tcaTemplate = array( 'ctrl' => array( 'title' => 'IRRE-Table', 'label' => 'uid', 'tstamp' => 'tstamp', 'crdate' => 'crdate', 'cruser_id' => 'cruser_id', 'dividers2tabs' => true, 'versioningWS' => true, 'languageField' => 'sys_language_uid', 'transOrigPointerField' => 'l10n_parent', 'transOrigDiffSourceField' => 'l10n_diffsource', 'delete' => 'deleted', 'enablecolumns' => array( 'disabled' => 'hidden', 'starttime' => 'starttime', 'endtime' => 'endtime', ), 'searchFields' => '', 'dynamicConfigFile' => '', 'iconfile' => '' ), 'interface' => array( 'showRecordFieldList' => 'sys_language_uid, l10n_parent, l10n_diffsource, hidden, ', ), 'types' => array( '1' => array('showitem' => 'sys_language_uid;;;;1-1-1, l10n_parent, l10n_diffsource, hidden;;1, --div--;LLL:EXT:cms/locallang_ttc.xlf:tabs.access, starttime, endtime'), ), 'palettes' => array( '1' => array('showitem' => ''), ), 'columns' => array( 'sys_language_uid' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.language', 'config' => array( 'type' => 'select', 'renderType' => 'selectSingle', 'items' => array( array('LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.allLanguages', -1, 'flags-multiple'), ), 'special' => 'languages', 'default' => 0 ), ), 'l10n_parent' => array( 'displayCond' => 'FIELD:sys_language_uid:>:0', 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.l18n_parent', 'config' => array( 'type' => 'select', 'renderType' => 'selectSingle', 'items' => array( array('', 0), ), 'foreign_table' => 'tx_test_domain_model_murph', 'foreign_table_where' => 'AND tx_test_domain_model_murph.pid=###CURRENT_PID### AND tx_test_domain_model_murph.sys_language_uid IN (-1,0)', 'default' => 0, ), ), 'l10n_diffsource' => array( 'config' => array( 'type' => 'passthrough', ), ), 't3ver_label' => array( 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.versionLabel', 'config' => array( 'type' => 'input', 'size' => 30, 'max' => 255, ) ), 'hidden' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.hidden', 'config' => array( 'type' => 'check', ), ), 'starttime' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.starttime', 'config' => array( 'behaviour' => array( 'allowLanguageSynchronization' => true ), 'renderType' => 'inputDateTime', 'type' => 'input', 'size' => 13, 'eval' => 'datetime,int', 'checkbox' => 0, 'default' => 0 ), ), 'endtime' => array( 'exclude' => 1, 'label' => 'LLL:EXT:core/Resources/Private/Language/locallang_general.xlf:LGL.endtime', 'config' => array( 'behaviour' => array( 'allowLanguageSynchronization' => true ), 'renderType' => 'inputDateTime', 'type' => 'input', 'size' => 13, 'eval' => 'datetime,int', 'checkbox' => 0, 'default' => 0 ), ), 'parentid' => array( 'config' => array( 'type' => 'select', 'renderType' => 'selectSingle', 'items' => array( array('', 0), ), 'foreign_table' => 'tt_content', 'foreign_table_where' => 'AND tt_content.pid=###CURRENT_PID### AND tt_content.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)', ), ), 'parenttable' => array( 'config' => array( 'type' => 'passthrough', ), ), 'sorting' => array( 'config' => array( 'type' => 'passthrough', ), ), ), ); $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $generalUtility = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Utility\\GeneralUtility'); // now add all the fields that should be shown $prependTabs = "sys_language_uid, l10n_parent, l10n_diffsource, hidden, "; if ($tca) { $i = 0; uasort($tca, function ($columnA, $columnB) { $a = isset($columnA['order']) ? (int)$columnA['order'] : 0; $b = isset($columnB['order']) ? (int)$columnB['order'] : 0; return $a - $b; }); foreach ($tca as $fieldKey => $configuration) { // check if this field is of type tab $formType = $fieldHelper->getFormType($fieldKey, "", $table); if ($formType == "Tab") { $label = $configuration["label"]; // if a tab is in the first position then change the name of the general tab if ($i === 0) { $prependTabs = '--div--;' . $label . "," . $prependTabs; } else { // otherwise just add new tab $fields[] = '--div--;' . $label; } } else { $fields[] = $fieldKey; } $i++; } } // take first field for inline label if (!empty($fields)) { $labelField = $generalUtility->getFirstNoneTabField($fields); } // get parent table of this inline table $parentTable = $fieldHelper->getFieldType($table); // Adjust TCA-Template $tableTca = $tcaTemplate; $tableTca["ctrl"]["title"] = $table; $tableTca["ctrl"]["label"] = $labelField; $tableTca["ctrl"]["searchFields"] = implode(",", (array)$fields); $tableTca["interface"]["showRecordFieldList"] = "sys_language_uid, l10n_parent, l10n_diffsource, hidden, " . implode(", ", (array)$fields); $tableTca["types"]["1"]["showitem"] = $prependTabs . implode(", ", (array)$fields) . ", --div--;LLL:EXT:frontend/Resources/Private/Language/locallang_ttc.xlf:tabs.access, starttime, endtime"; $tableTca["columns"]["l10n_parent"]["config"]["foreign_table"] = $table; $tableTca["columns"]["l10n_parent"]["config"]["foreign_table_where"] = 'AND ' . $table . '.pid=###CURRENT_PID### AND ' . $table . '.sys_language_uid IN (-1,0)'; $tableTca["columns"]["parentid"]["config"]["foreign_table"] = $parentTable; $tableTca["columns"]["parentid"]["config"]["foreign_table_where"] = 'AND ' . $parentTable . '.pid=###CURRENT_PID### AND ' . $parentTable . '.sys_language_uid IN (-1,###REC_FIELD_sys_language_uid###)'; // Add some stuff we need to make irre work like it should $GLOBALS["TCA"][$table] = $tableTca; }
[ "public", "function", "generateTableTca", "(", "$", "table", ",", "$", "tca", ")", "{", "$", "tcaTemplate", "=", "array", "(", "'ctrl'", "=>", "array", "(", "'title'", "=>", "'IRRE-Table'", ",", "'label'", "=>", "'uid'", ",", "'tstamp'", "=>", "'tstamp'", ...
Generates the TCA for Inline-Tables @param string $table @param array $tca @return string @author Benjamin Butschell <bb@webprofil.at>
[ "Generates", "the", "TCA", "for", "Inline", "-", "Tables" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TcaCodeGenerator.php#L332-L530
Gernott/mask
Classes/CodeGenerator/TcaCodeGenerator.php
TcaCodeGenerator.allowInlineTablesOnStandardPages
public function allowInlineTablesOnStandardPages($configuration) { $notIrreTables = array("pages", "tt_content", "sys_file_reference"); if ($configuration) { foreach ($configuration as $table => $subJson) { if (array_search($table, $notIrreTables) === false) { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages($table); } } } }
php
public function allowInlineTablesOnStandardPages($configuration) { $notIrreTables = array("pages", "tt_content", "sys_file_reference"); if ($configuration) { foreach ($configuration as $table => $subJson) { if (array_search($table, $notIrreTables) === false) { \TYPO3\CMS\Core\Utility\ExtensionManagementUtility::allowTableOnStandardPages($table); } } } }
[ "public", "function", "allowInlineTablesOnStandardPages", "(", "$", "configuration", ")", "{", "$", "notIrreTables", "=", "array", "(", "\"pages\"", ",", "\"tt_content\"", ",", "\"sys_file_reference\"", ")", ";", "if", "(", "$", "configuration", ")", "{", "foreach...
allow all inline tables on standard pages @param array $configuration
[ "allow", "all", "inline", "tables", "on", "standard", "pages" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TcaCodeGenerator.php#L537-L547
Gernott/mask
Classes/Domain/Repository/BackendLayoutRepository.php
BackendLayoutRepository.initializeObject
public function initializeObject() { /** @var $querySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */ $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings'); $querySettings->setRespectStoragePage(false); $this->setDefaultQuerySettings($querySettings); $this->backendLayoutView = GeneralUtility::makeInstance(\MASK\Mask\Backend\BackendLayoutView::class); }
php
public function initializeObject() { /** @var $querySettings \TYPO3\CMS\Extbase\Persistence\Generic\Typo3QuerySettings */ $querySettings = $this->objectManager->get('TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings'); $querySettings->setRespectStoragePage(false); $this->setDefaultQuerySettings($querySettings); $this->backendLayoutView = GeneralUtility::makeInstance(\MASK\Mask\Backend\BackendLayoutView::class); }
[ "public", "function", "initializeObject", "(", ")", "{", "/** @var $querySettings \\TYPO3\\CMS\\Extbase\\Persistence\\Generic\\Typo3QuerySettings */", "$", "querySettings", "=", "$", "this", "->", "objectManager", "->", "get", "(", "'TYPO3\\\\CMS\\\\Extbase\\\\Persistence\\\\Generi...
Initializes the repository. @return void
[ "Initializes", "the", "repository", "." ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Domain/Repository/BackendLayoutRepository.php#L54-L61
Gernott/mask
Classes/Domain/Repository/BackendLayoutRepository.php
BackendLayoutRepository.findAll
public function findAll($pageTsPids = array()) { $backendLayouts = array(); // search all the pids for backend layouts defined in the pageTS foreach ($pageTsPids as $pid) { $pageTsConfig = (array)\TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($pid); $dataProviderContext = $this->backendLayoutView->createDataProviderContext()->setPageTsConfig($pageTsConfig); $backendLayoutCollections = $this->backendLayoutView->getDataProviderCollection()->getBackendLayoutCollections($dataProviderContext); foreach ($backendLayoutCollections["default"]->getAll() as $backendLayout) { $backendLayouts[$backendLayout->getIdentifier()] = $backendLayout; } foreach ($backendLayoutCollections["pagets"]->getAll() as $backendLayout) { $backendLayouts[$backendLayout->getIdentifier()] = $backendLayout; } } // also search in the database for backendlayouts $databaseBackendLayouts = parent::findAll(); foreach ($databaseBackendLayouts as $layout) { $backendLayout = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayout($layout->getUid(), $layout->getTitle(), ""); if ($layout->getIcon()) { $backendLayout->setIconPath('/uploads/media/' . $layout->getIcon()); } $backendLayout->setDescription($layout->getDescription()); $backendLayouts[$backendLayout->getIdentifier()] = $backendLayout; } return $backendLayouts; }
php
public function findAll($pageTsPids = array()) { $backendLayouts = array(); // search all the pids for backend layouts defined in the pageTS foreach ($pageTsPids as $pid) { $pageTsConfig = (array)\TYPO3\CMS\Backend\Utility\BackendUtility::getPagesTSconfig($pid); $dataProviderContext = $this->backendLayoutView->createDataProviderContext()->setPageTsConfig($pageTsConfig); $backendLayoutCollections = $this->backendLayoutView->getDataProviderCollection()->getBackendLayoutCollections($dataProviderContext); foreach ($backendLayoutCollections["default"]->getAll() as $backendLayout) { $backendLayouts[$backendLayout->getIdentifier()] = $backendLayout; } foreach ($backendLayoutCollections["pagets"]->getAll() as $backendLayout) { $backendLayouts[$backendLayout->getIdentifier()] = $backendLayout; } } // also search in the database for backendlayouts $databaseBackendLayouts = parent::findAll(); foreach ($databaseBackendLayouts as $layout) { $backendLayout = new \TYPO3\CMS\Backend\View\BackendLayout\BackendLayout($layout->getUid(), $layout->getTitle(), ""); if ($layout->getIcon()) { $backendLayout->setIconPath('/uploads/media/' . $layout->getIcon()); } $backendLayout->setDescription($layout->getDescription()); $backendLayouts[$backendLayout->getIdentifier()] = $backendLayout; } return $backendLayouts; }
[ "public", "function", "findAll", "(", "$", "pageTsPids", "=", "array", "(", ")", ")", "{", "$", "backendLayouts", "=", "array", "(", ")", ";", "// search all the pids for backend layouts defined in the pageTS", "foreach", "(", "$", "pageTsPids", "as", "$", "pid", ...
Returns all backendlayouts defined, database and pageTs @param array $pageTsPids @return array
[ "Returns", "all", "backendlayouts", "defined", "database", "and", "pageTs" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Domain/Repository/BackendLayoutRepository.php#L68-L97
Gernott/mask
Classes/Domain/Repository/BackendLayoutRepository.php
BackendLayoutRepository.findByIdentifier
public function findByIdentifier($identifier, $pageTsPids = array()) { $backendLayouts = $this->findAll($pageTsPids); if (isset($backendLayouts[$identifier])) { return $backendLayouts[$identifier]; } else { return null; } }
php
public function findByIdentifier($identifier, $pageTsPids = array()) { $backendLayouts = $this->findAll($pageTsPids); if (isset($backendLayouts[$identifier])) { return $backendLayouts[$identifier]; } else { return null; } }
[ "public", "function", "findByIdentifier", "(", "$", "identifier", ",", "$", "pageTsPids", "=", "array", "(", ")", ")", "{", "$", "backendLayouts", "=", "$", "this", "->", "findAll", "(", "$", "pageTsPids", ")", ";", "if", "(", "isset", "(", "$", "backe...
Returns a backendlayout or null, if non found @param $identifier @param array $pageTsPids @return \TYPO3\CMS\Backend\View\BackendLayout\BackendLayout
[ "Returns", "a", "backendlayout", "or", "null", "if", "non", "found" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Domain/Repository/BackendLayoutRepository.php#L151-L159
Gernott/mask
Classes/ViewHelpers/LinkViewHelper.php
LinkViewHelper.render
public function render(): string { $templatePath = MaskUtility::getTemplatePath( $this->settingsService->get(), $this->arguments['data'] ); $content = ''; if (!file_exists($templatePath) || !is_file($templatePath)) { $content = '<div class="alert alert-warning"><div class="media"> <div class="media-left"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i> <i class="fa fa-exclamation fa-stack-1x"></i></span></div> <div class="media-body"><h4 class="alert-title">' . LocalizationUtility::translate('tx_mask.content.htmlmissing', 'mask') . '</h4> <p class="alert-message">' . $templatePath . ' </p></div></div></div>'; } return $content; }
php
public function render(): string { $templatePath = MaskUtility::getTemplatePath( $this->settingsService->get(), $this->arguments['data'] ); $content = ''; if (!file_exists($templatePath) || !is_file($templatePath)) { $content = '<div class="alert alert-warning"><div class="media"> <div class="media-left"><span class="fa-stack fa-lg"><i class="fa fa-circle fa-stack-2x"></i> <i class="fa fa-exclamation fa-stack-1x"></i></span></div> <div class="media-body"><h4 class="alert-title">' . LocalizationUtility::translate('tx_mask.content.htmlmissing', 'mask') . '</h4> <p class="alert-message">' . $templatePath . ' </p></div></div></div>'; } return $content; }
[ "public", "function", "render", "(", ")", ":", "string", "{", "$", "templatePath", "=", "MaskUtility", "::", "getTemplatePath", "(", "$", "this", "->", "settingsService", "->", "get", "(", ")", ",", "$", "this", "->", "arguments", "[", "'data'", "]", ")"...
Checks Links for BE-module @return string all irre elements of this attribut @author Gernot Ploiner <gp@webprofil.at>
[ "Checks", "Links", "for", "BE", "-", "module" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/ViewHelpers/LinkViewHelper.php#L55-L72
Gernott/mask
Classes/ViewHelpers/TranslateLabelViewHelper.php
TranslateLabelViewHelper.render
public function render() { $key = $this->arguments['key']; $extensionName = $this->arguments['extensionName']; if (empty($key) || strpos($key, 'LLL') > 0) { return $key; } $request = $this->renderingContext->getControllerContext()->getRequest(); $extensionName = $extensionName === null ? $request->getControllerExtensionName() : $extensionName; $result = LocalizationUtility::translate($key, $extensionName); return (empty($result) ? $key : $result); }
php
public function render() { $key = $this->arguments['key']; $extensionName = $this->arguments['extensionName']; if (empty($key) || strpos($key, 'LLL') > 0) { return $key; } $request = $this->renderingContext->getControllerContext()->getRequest(); $extensionName = $extensionName === null ? $request->getControllerExtensionName() : $extensionName; $result = LocalizationUtility::translate($key, $extensionName); return (empty($result) ? $key : $result); }
[ "public", "function", "render", "(", ")", "{", "$", "key", "=", "$", "this", "->", "arguments", "[", "'key'", "]", ";", "$", "extensionName", "=", "$", "this", "->", "arguments", "[", "'extensionName'", "]", ";", "if", "(", "empty", "(", "$", "key", ...
The given key will be translated. If the result is empty, the key will be returned. @return string
[ "The", "given", "key", "will", "be", "translated", ".", "If", "the", "result", "is", "empty", "the", "key", "will", "be", "returned", "." ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/ViewHelpers/TranslateLabelViewHelper.php#L34-L47
Gernott/mask
Classes/ViewHelpers/TcaViewHelper.php
TcaViewHelper.render
public function render() { $table = $this->arguments['table']; $type = $this->arguments['type']; if (empty($GLOBALS['TCA'][$table])) { return []; } $fields = []; if ($type === 'Tab') { $fields = $this->fieldHelper->getFieldsByType($type, $table); } else { if (in_array($table, ['tt_content', 'pages'])) { foreach ($GLOBALS['TCA'][$table]['columns'] as $tcaField => $tcaConfig) { if ($table === 'tt_content' || ($table === 'pages' && strpos($tcaField, 'tx_mask_') === 0)) { $fieldType = $this->fieldHelper->getFormType($tcaField, '', $table); if (($fieldType === $type || ($fieldType === 'Text' && $type === 'Richtext')) && !in_array($tcaField, self::$forbiddenFields, true) ) { $fields[] = [ 'field' => $tcaField, 'label' => $tcaConfig['label'], ]; } } } } } return $fields; }
php
public function render() { $table = $this->arguments['table']; $type = $this->arguments['type']; if (empty($GLOBALS['TCA'][$table])) { return []; } $fields = []; if ($type === 'Tab') { $fields = $this->fieldHelper->getFieldsByType($type, $table); } else { if (in_array($table, ['tt_content', 'pages'])) { foreach ($GLOBALS['TCA'][$table]['columns'] as $tcaField => $tcaConfig) { if ($table === 'tt_content' || ($table === 'pages' && strpos($tcaField, 'tx_mask_') === 0)) { $fieldType = $this->fieldHelper->getFormType($tcaField, '', $table); if (($fieldType === $type || ($fieldType === 'Text' && $type === 'Richtext')) && !in_array($tcaField, self::$forbiddenFields, true) ) { $fields[] = [ 'field' => $tcaField, 'label' => $tcaConfig['label'], ]; } } } } } return $fields; }
[ "public", "function", "render", "(", ")", "{", "$", "table", "=", "$", "this", "->", "arguments", "[", "'table'", "]", ";", "$", "type", "=", "$", "this", "->", "arguments", "[", "'type'", "]", ";", "if", "(", "empty", "(", "$", "GLOBALS", "[", "...
Generates TCA Selectbox-Options-Array for a specific TCA-type. @return array all TCA elements of this attribut @author Gernot Ploiner <gp@webprofil.at> @author Benjamin Butschell <bb@webprofil.at>
[ "Generates", "TCA", "Selectbox", "-", "Options", "-", "Array", "for", "a", "specific", "TCA", "-", "type", "." ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/ViewHelpers/TcaViewHelper.php#L103-L133
Gernott/mask
Classes/ViewHelpers/ContentViewHelper.php
ContentViewHelper.injectConfigurationManager
public function injectConfigurationManager( \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager ) { $this->configurationManager = $configurationManager; $this->cObj = $this->configurationManager->getContentObject(); }
php
public function injectConfigurationManager( \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager ) { $this->configurationManager = $configurationManager; $this->cObj = $this->configurationManager->getContentObject(); }
[ "public", "function", "injectConfigurationManager", "(", "\\", "TYPO3", "\\", "CMS", "\\", "Extbase", "\\", "Configuration", "\\", "ConfigurationManagerInterface", "$", "configurationManager", ")", "{", "$", "this", "->", "configurationManager", "=", "$", "configurati...
Injects Configuration Manager @param \TYPO3\CMS\Extbase\Configuration\ConfigurationManagerInterface $configurationManager @return void
[ "Injects", "Configuration", "Manager" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/ViewHelpers/ContentViewHelper.php#L55-L60
Gernott/mask
Classes/CodeGenerator/TyposcriptCodeGenerator.php
TyposcriptCodeGenerator.generateTsConfig
public function generateTsConfig($json) { // generate page TSconfig $content = ""; $iconRegistry = GeneralUtility::makeInstance("TYPO3\CMS\Core\Imaging\IconRegistry"); // make content-Elements if ($json["tt_content"]["elements"]) { foreach ($json["tt_content"]["elements"] as $element) { // Register icons for contentelements $iconIdentifier = 'mask-ce-' . $element["key"]; $iconRegistry->registerIcon( $iconIdentifier, "MASK\Mask\Imaging\IconProvider\ContentElementIconProvider", array( 'contentElementKey' => $element["key"] ) ); if (!$element["hidden"]) { // add the content element wizard for each content element $wizard = [ 'header' => 'LLL:EXT:mask/Resources/Private/Language/locallang_mask.xlf:new_content_element_tab', 'elements.mask_' . $element["key"] => [ 'iconIdentifier' => $iconIdentifier, 'title' => $element["label"], 'description' => $element["description"], 'tt_content_defValues' => [ 'CType' => 'mask_' . $element["key"] ] ], ]; $content .= "mod.wizards.newContentElement.wizardItems.mask {\n"; $content .= $this->convertArrayToTypoScript($wizard, '', 1); $content .= "\tshow := addToList(mask_" . $element["key"] . ");\n"; $content .= "}\n"; // and switch the labels depending on which content element is selected $content .= "\n[userFunc = user_mask_contentType(CType|mask_" . $element["key"] . ")]\n"; if ($element["columns"]) { foreach ($element["columns"] as $index => $column) { $content .= " TCEFORM.tt_content." . $column . ".label = " . $element["labels"][$index] . "\n"; } } $content .= "[end]\n\n"; } } } return $content; }
php
public function generateTsConfig($json) { // generate page TSconfig $content = ""; $iconRegistry = GeneralUtility::makeInstance("TYPO3\CMS\Core\Imaging\IconRegistry"); // make content-Elements if ($json["tt_content"]["elements"]) { foreach ($json["tt_content"]["elements"] as $element) { // Register icons for contentelements $iconIdentifier = 'mask-ce-' . $element["key"]; $iconRegistry->registerIcon( $iconIdentifier, "MASK\Mask\Imaging\IconProvider\ContentElementIconProvider", array( 'contentElementKey' => $element["key"] ) ); if (!$element["hidden"]) { // add the content element wizard for each content element $wizard = [ 'header' => 'LLL:EXT:mask/Resources/Private/Language/locallang_mask.xlf:new_content_element_tab', 'elements.mask_' . $element["key"] => [ 'iconIdentifier' => $iconIdentifier, 'title' => $element["label"], 'description' => $element["description"], 'tt_content_defValues' => [ 'CType' => 'mask_' . $element["key"] ] ], ]; $content .= "mod.wizards.newContentElement.wizardItems.mask {\n"; $content .= $this->convertArrayToTypoScript($wizard, '', 1); $content .= "\tshow := addToList(mask_" . $element["key"] . ");\n"; $content .= "}\n"; // and switch the labels depending on which content element is selected $content .= "\n[userFunc = user_mask_contentType(CType|mask_" . $element["key"] . ")]\n"; if ($element["columns"]) { foreach ($element["columns"] as $index => $column) { $content .= " TCEFORM.tt_content." . $column . ".label = " . $element["labels"][$index] . "\n"; } } $content .= "[end]\n\n"; } } } return $content; }
[ "public", "function", "generateTsConfig", "(", "$", "json", ")", "{", "// generate page TSconfig", "$", "content", "=", "\"\"", ";", "$", "iconRegistry", "=", "GeneralUtility", "::", "makeInstance", "(", "\"TYPO3\\CMS\\Core\\Imaging\\IconRegistry\"", ")", ";", "// mak...
Generates the tsConfig typoscript and registers the icons for the content elements @param array $json @return string
[ "Generates", "the", "tsConfig", "typoscript", "and", "registers", "the", "icons", "for", "the", "content", "elements" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TyposcriptCodeGenerator.php#L48-L97
Gernott/mask
Classes/CodeGenerator/TyposcriptCodeGenerator.php
TyposcriptCodeGenerator.generatePageTyposcript
public function generatePageTyposcript($json) { $pageColumns = array(); $disableColumns = ""; $pagesContent = ""; if ($json["pages"]["elements"]) { foreach ($json["pages"]["elements"] as $element) { // Labels for pages $pagesContent .= "\n[userFunc = user_mask_beLayout(" . $element["key"] . ")]\n"; // if page has backendlayout with this element-key if ($element["columns"]) { foreach ($element["columns"] as $index => $column) { $pagesContent .= " TCEFORM.pages." . $column . ".label = " . $element["labels"][$index] . "\n"; } $pagesContent .= "\n"; foreach ($element["columns"] as $index => $column) { $pageColumns[] = $column; $pagesContent .= " TCEFORM.pages." . $column . ".disabled = 0\n"; } } $pagesContent .= "[end]\n"; } } // disable all fields by default and only activate by condition foreach ($pageColumns as $column) { $disableColumns .= "TCEFORM.pages." . $column . ".disabled = 1\n"; } $pagesContent = $disableColumns . "\n" . $pagesContent; return $pagesContent; }
php
public function generatePageTyposcript($json) { $pageColumns = array(); $disableColumns = ""; $pagesContent = ""; if ($json["pages"]["elements"]) { foreach ($json["pages"]["elements"] as $element) { // Labels for pages $pagesContent .= "\n[userFunc = user_mask_beLayout(" . $element["key"] . ")]\n"; // if page has backendlayout with this element-key if ($element["columns"]) { foreach ($element["columns"] as $index => $column) { $pagesContent .= " TCEFORM.pages." . $column . ".label = " . $element["labels"][$index] . "\n"; } $pagesContent .= "\n"; foreach ($element["columns"] as $index => $column) { $pageColumns[] = $column; $pagesContent .= " TCEFORM.pages." . $column . ".disabled = 0\n"; } } $pagesContent .= "[end]\n"; } } // disable all fields by default and only activate by condition foreach ($pageColumns as $column) { $disableColumns .= "TCEFORM.pages." . $column . ".disabled = 1\n"; } $pagesContent = $disableColumns . "\n" . $pagesContent; return $pagesContent; }
[ "public", "function", "generatePageTyposcript", "(", "$", "json", ")", "{", "$", "pageColumns", "=", "array", "(", ")", ";", "$", "disableColumns", "=", "\"\"", ";", "$", "pagesContent", "=", "\"\"", ";", "if", "(", "$", "json", "[", "\"pages\"", "]", ...
Generates the typoscript for pages @param array $json @return string
[ "Generates", "the", "typoscript", "for", "pages" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TyposcriptCodeGenerator.php#L104-L133
Gernott/mask
Classes/CodeGenerator/TyposcriptCodeGenerator.php
TyposcriptCodeGenerator.generateSetupTyposcript
public function generateSetupTyposcript($configuration, $settings) { // generate TypoScript setup $setupContent = []; // for backend module $setupContent[] = $this->convertArrayToTypoScript([ 'view' => [ 'templateRootPaths' => [ 10 => 'EXT:mask/Resources/Private/Backend/Templates/' ], 'partialRootPaths' => [ 10 => 'EXT:mask/Resources/Private/Backend/Partials/' ], 'layoutRootPaths' => [ 10 => 'EXT:mask/Resources/Private/Backend/Layouts/' ] ], 'persistence' => [ 'classes' => [ BackendLayout::class => [ 'mapping' => [ 'tableName' => 'backend_layout', 'columns' => [ 'uid.mapOnProperty' => 'uid', 'title.mapOnProperty' => 'title' ] ] ] ] ] ], 'module.tx_mask'); // for base paths to fluid templates configured in extension settings $setupContent[] = $this->convertArrayToTypoScript([ 'templateRootPaths' => [ 10 => rtrim($settings['content'], '/') . '/' ], 'partialRootPaths' => [ 10 => rtrim($settings['partials'], '/') . '/' ], 'layoutRootPaths' => [ 10 => rtrim($settings['layouts'], '/') . '/' ] ], 'lib.maskContentElement'); // for each content element if ($configuration["tt_content"]["elements"]) { foreach ($configuration["tt_content"]["elements"] as $element) { if (!$element["hidden"]) { $setupContent[] = "tt_content.mask_" . $element["key"] . " =< lib.maskContentElement\ntt_content.mask_" . $element["key"] . " {\ntemplateName = " . MaskUtility::getTemplatePath( $settings, $element['key'], true ) . "\n}\n\n"; } } } return implode("\n\n", $setupContent); }
php
public function generateSetupTyposcript($configuration, $settings) { // generate TypoScript setup $setupContent = []; // for backend module $setupContent[] = $this->convertArrayToTypoScript([ 'view' => [ 'templateRootPaths' => [ 10 => 'EXT:mask/Resources/Private/Backend/Templates/' ], 'partialRootPaths' => [ 10 => 'EXT:mask/Resources/Private/Backend/Partials/' ], 'layoutRootPaths' => [ 10 => 'EXT:mask/Resources/Private/Backend/Layouts/' ] ], 'persistence' => [ 'classes' => [ BackendLayout::class => [ 'mapping' => [ 'tableName' => 'backend_layout', 'columns' => [ 'uid.mapOnProperty' => 'uid', 'title.mapOnProperty' => 'title' ] ] ] ] ] ], 'module.tx_mask'); // for base paths to fluid templates configured in extension settings $setupContent[] = $this->convertArrayToTypoScript([ 'templateRootPaths' => [ 10 => rtrim($settings['content'], '/') . '/' ], 'partialRootPaths' => [ 10 => rtrim($settings['partials'], '/') . '/' ], 'layoutRootPaths' => [ 10 => rtrim($settings['layouts'], '/') . '/' ] ], 'lib.maskContentElement'); // for each content element if ($configuration["tt_content"]["elements"]) { foreach ($configuration["tt_content"]["elements"] as $element) { if (!$element["hidden"]) { $setupContent[] = "tt_content.mask_" . $element["key"] . " =< lib.maskContentElement\ntt_content.mask_" . $element["key"] . " {\ntemplateName = " . MaskUtility::getTemplatePath( $settings, $element['key'], true ) . "\n}\n\n"; } } } return implode("\n\n", $setupContent); }
[ "public", "function", "generateSetupTyposcript", "(", "$", "configuration", ",", "$", "settings", ")", "{", "// generate TypoScript setup", "$", "setupContent", "=", "[", "]", ";", "// for backend module", "$", "setupContent", "[", "]", "=", "$", "this", "->", "...
Generates the typoscript for the setup field @param array $configuration @param array $settings @return string
[ "Generates", "the", "typoscript", "for", "the", "setup", "field" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TyposcriptCodeGenerator.php#L141-L203
Gernott/mask
Classes/CodeGenerator/TyposcriptCodeGenerator.php
TyposcriptCodeGenerator.convertArrayToTypoScript
protected function convertArrayToTypoScript(array $typoScriptArray, $addKey = '', $tab = 0, $init = true) { $typoScript = ''; if ($addKey !== '') { $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . $addKey . " {\n"; if ($init === true) { $tab++; } } $tab++; foreach ($typoScriptArray as $key => $value) { if (!is_array($value)) { if (strpos($value, "\n") === false) { $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . "$key = $value\n"; } else { $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . "$key (\n$value\n" . str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . ")\n"; } } else { $typoScript .= $this->convertArrayToTypoScript($value, $key, $tab, false); } } if ($addKey !== '') { $tab--; $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . '}'; if ($init !== true) { $typoScript .= "\n"; } } return $typoScript; }
php
protected function convertArrayToTypoScript(array $typoScriptArray, $addKey = '', $tab = 0, $init = true) { $typoScript = ''; if ($addKey !== '') { $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . $addKey . " {\n"; if ($init === true) { $tab++; } } $tab++; foreach ($typoScriptArray as $key => $value) { if (!is_array($value)) { if (strpos($value, "\n") === false) { $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . "$key = $value\n"; } else { $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . "$key (\n$value\n" . str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . ")\n"; } } else { $typoScript .= $this->convertArrayToTypoScript($value, $key, $tab, false); } } if ($addKey !== '') { $tab--; $typoScript .= str_repeat("\t", ($tab === 0) ? $tab : $tab - 1) . '}'; if ($init !== true) { $typoScript .= "\n"; } } return $typoScript; }
[ "protected", "function", "convertArrayToTypoScript", "(", "array", "$", "typoScriptArray", ",", "$", "addKey", "=", "''", ",", "$", "tab", "=", "0", ",", "$", "init", "=", "true", ")", "{", "$", "typoScript", "=", "''", ";", "if", "(", "$", "addKey", ...
Converts given array to TypoScript @param array $typoScriptArray The array to convert to string @param string $addKey Prefix given values with given key (eg. lib.whatever = {...}) @param integer $tab Internal @param boolean $init Internal @return string TypoScript
[ "Converts", "given", "array", "to", "TypoScript" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/TyposcriptCodeGenerator.php#L214-L245
Gernott/mask
Classes/Controller/WizardPageController.php
WizardPageController.newAction
public function newAction() { $settings = $this->settingsService->get(); $backendLayouts = $this->backendLayoutRepository->findAll(explode(",", $settings['backendlayout_pids'])); $this->view->assign('backendLayouts', $backendLayouts); }
php
public function newAction() { $settings = $this->settingsService->get(); $backendLayouts = $this->backendLayoutRepository->findAll(explode(",", $settings['backendlayout_pids'])); $this->view->assign('backendLayouts', $backendLayouts); }
[ "public", "function", "newAction", "(", ")", "{", "$", "settings", "=", "$", "this", "->", "settingsService", "->", "get", "(", ")", ";", "$", "backendLayouts", "=", "$", "this", "->", "backendLayoutRepository", "->", "findAll", "(", "explode", "(", "\",\"...
action new @return void
[ "action", "new" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardPageController.php#L64-L69
Gernott/mask
Classes/Controller/WizardPageController.php
WizardPageController.createAction
public function createAction($storage) { $this->storageRepository->add($storage); $this->generateAction(); $this->addFlashMessage('Your new Content-Element was created.'); $this->redirect('list'); }
php
public function createAction($storage) { $this->storageRepository->add($storage); $this->generateAction(); $this->addFlashMessage('Your new Content-Element was created.'); $this->redirect('list'); }
[ "public", "function", "createAction", "(", "$", "storage", ")", "{", "$", "this", "->", "storageRepository", "->", "add", "(", "$", "storage", ")", ";", "$", "this", "->", "generateAction", "(", ")", ";", "$", "this", "->", "addFlashMessage", "(", "'Your...
action create @param array $storage @return void
[ "action", "create" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardPageController.php#L77-L83
Gernott/mask
Classes/Controller/WizardPageController.php
WizardPageController.editAction
public function editAction($layoutIdentifier = null) { $settings = $this->settingsService->get(); $layout = $this->backendLayoutRepository->findByIdentifier($layoutIdentifier, explode(",", $settings['backendlayout_pids'])); if ($layout) { $storage = $this->storageRepository->loadElement("pages", $layoutIdentifier); $this->prepareStorage($storage); $this->view->assign('backendLayout', $layout); $this->view->assign('storage', $storage); $this->view->assign('editMode', 1); } }
php
public function editAction($layoutIdentifier = null) { $settings = $this->settingsService->get(); $layout = $this->backendLayoutRepository->findByIdentifier($layoutIdentifier, explode(",", $settings['backendlayout_pids'])); if ($layout) { $storage = $this->storageRepository->loadElement("pages", $layoutIdentifier); $this->prepareStorage($storage); $this->view->assign('backendLayout', $layout); $this->view->assign('storage', $storage); $this->view->assign('editMode', 1); } }
[ "public", "function", "editAction", "(", "$", "layoutIdentifier", "=", "null", ")", "{", "$", "settings", "=", "$", "this", "->", "settingsService", "->", "get", "(", ")", ";", "$", "layout", "=", "$", "this", "->", "backendLayoutRepository", "->", "findBy...
action edit @param string $layoutIdentifier @return void
[ "action", "edit" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardPageController.php#L91-L104
Gernott/mask
Classes/Controller/WizardPageController.php
WizardPageController.updateAction
public function updateAction($storage) { $this->storageRepository->update($storage); $this->generateAction(); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.page.updatedpage', 'mask')); $this->redirectByAction(); }
php
public function updateAction($storage) { $this->storageRepository->update($storage); $this->generateAction(); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.page.updatedpage', 'mask')); $this->redirectByAction(); }
[ "public", "function", "updateAction", "(", "$", "storage", ")", "{", "$", "this", "->", "storageRepository", "->", "update", "(", "$", "storage", ")", ";", "$", "this", "->", "generateAction", "(", ")", ";", "$", "this", "->", "addFlashMessage", "(", "\\...
action update @param array $storage @return void
[ "action", "update" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardPageController.php#L112-L119
Gernott/mask
Classes/Controller/WizardPageController.php
WizardPageController.deleteAction
public function deleteAction(array $storage) { $this->storageRepository->remove($storage); $this->addFlashMessage('Your Page was removed.'); $this->redirect('list'); }
php
public function deleteAction(array $storage) { $this->storageRepository->remove($storage); $this->addFlashMessage('Your Page was removed.'); $this->redirect('list'); }
[ "public", "function", "deleteAction", "(", "array", "$", "storage", ")", "{", "$", "this", "->", "storageRepository", "->", "remove", "(", "$", "storage", ")", ";", "$", "this", "->", "addFlashMessage", "(", "'Your Page was removed.'", ")", ";", "$", "this",...
action delete @param array $storage @return void
[ "action", "delete" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardPageController.php#L127-L132
Gernott/mask
Classes/CodeGenerator/HtmlCodeGenerator.php
HtmlCodeGenerator.generateHtml
public function generateHtml($key, $table) { $storage = $this->storageRepository->loadElement($table, $key); $html = ""; if ($storage["tca"]) { foreach ($storage["tca"] as $fieldKey => $fieldConfig) { $html .= $this->generateFieldHtml($fieldKey, $key, $table); } } return $html; }
php
public function generateHtml($key, $table) { $storage = $this->storageRepository->loadElement($table, $key); $html = ""; if ($storage["tca"]) { foreach ($storage["tca"] as $fieldKey => $fieldConfig) { $html .= $this->generateFieldHtml($fieldKey, $key, $table); } } return $html; }
[ "public", "function", "generateHtml", "(", "$", "key", ",", "$", "table", ")", "{", "$", "storage", "=", "$", "this", "->", "storageRepository", "->", "loadElement", "(", "$", "table", ",", "$", "key", ")", ";", "$", "html", "=", "\"\"", ";", "if", ...
Generates Fluid HTML for Contentelements @param string $key @param string $table @return string $html @author Gernot Ploiner <gp@webprofil.at>
[ "Generates", "Fluid", "HTML", "for", "Contentelements" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/HtmlCodeGenerator.php#L44-L54
Gernott/mask
Classes/CodeGenerator/HtmlCodeGenerator.php
HtmlCodeGenerator.generateFieldHtml
protected function generateFieldHtml($fieldKey, $elementKey, $table, $datafield = "data") { $html = ""; $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); switch ($fieldHelper->getFormType($fieldKey, $elementKey, $table)) { case "Check": $html .= "{f:if(condition: " . $datafield . "." . $fieldKey . ", then: 'On', else: 'Off')}<br />\n\n"; break; case "Content": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n"; $html .= '<f:cObject typoscriptObjectPath="lib.tx_mask.content">{' . $datafield . '_item.uid}</f:cObject><br />' . "\n"; $html .= "</f:for>\n"; $html .= "</f:if>\n\n"; break; case "Date": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.date format="d.m.Y">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Datetime": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.date format="d.m.Y - H:i:s">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "File": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:for each="{' . $datafield . '.' . $fieldKey . '}" as="file"> <f:image image="{file}" alt="{file.alternative}" title="{file.title}" width="200" /><br /> {file.description} / {file.identifier}<br /> </f:for>' . "\n"; $html .= "</f:if>\n\n"; break; case "Float": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{' . $datafield . '.' . $fieldKey . '}</f:format.number><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Inline": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= "<ul>\n"; $html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n<li>"; $inlineFields = $this->storageRepository->loadInlineFields($fieldKey); if ($inlineFields) { foreach ($inlineFields as $inlineField) { $html .= $this->generateFieldHtml($inlineField["maskKey"], $elementKey, $fieldKey, $datafield . "_item") . "\n"; } } $html .= "</li>\n</f:for>" . "\n"; $html .= "</ul>\n"; $html .= "</f:if>\n\n"; break; case "Integer": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Link": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:link.typolink parameter="{' . $datafield . '.' . $fieldKey . '}">{' . $datafield . '.' . $fieldKey . '}</f:link.typolink><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Radio": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}"> <f:case value="1">Value is: 1</f:case> <f:case value="2">Value is: 2</f:case> <f:case value="3">Value is: 3</f:case> </f:switch><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Richtext": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.html parseFuncTSPath="lib.parseFunc_RTE">{' . $datafield . '.' . $fieldKey . '}</f:format.html><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Select": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}"> <f:case value="1">Value is: 1</f:case> <f:case value="2">Value is: 2</f:case> <f:case value="3">Value is: 3</f:case> </f:switch><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "String": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Text": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.nl2br>{' . $datafield . '.' . $fieldKey . '}</f:format.nl2br><br />' . "\n"; $html .= "</f:if>\n\n"; break; } return $html; }
php
protected function generateFieldHtml($fieldKey, $elementKey, $table, $datafield = "data") { $html = ""; $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); switch ($fieldHelper->getFormType($fieldKey, $elementKey, $table)) { case "Check": $html .= "{f:if(condition: " . $datafield . "." . $fieldKey . ", then: 'On', else: 'Off')}<br />\n\n"; break; case "Content": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n"; $html .= '<f:cObject typoscriptObjectPath="lib.tx_mask.content">{' . $datafield . '_item.uid}</f:cObject><br />' . "\n"; $html .= "</f:for>\n"; $html .= "</f:if>\n\n"; break; case "Date": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.date format="d.m.Y">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Datetime": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.date format="d.m.Y - H:i:s">{' . $datafield . '.' . $fieldKey . '}</f:format.date><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "File": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:for each="{' . $datafield . '.' . $fieldKey . '}" as="file"> <f:image image="{file}" alt="{file.alternative}" title="{file.title}" width="200" /><br /> {file.description} / {file.identifier}<br /> </f:for>' . "\n"; $html .= "</f:if>\n\n"; break; case "Float": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.number decimals="2" decimalSeparator="," thousandsSeparator=".">{' . $datafield . '.' . $fieldKey . '}</f:format.number><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Inline": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= "<ul>\n"; $html .= "<f:for each=\"{" . $datafield . "." . $fieldKey . "}\" as=\"" . $datafield . "_item" . "\">\n<li>"; $inlineFields = $this->storageRepository->loadInlineFields($fieldKey); if ($inlineFields) { foreach ($inlineFields as $inlineField) { $html .= $this->generateFieldHtml($inlineField["maskKey"], $elementKey, $fieldKey, $datafield . "_item") . "\n"; } } $html .= "</li>\n</f:for>" . "\n"; $html .= "</ul>\n"; $html .= "</f:if>\n\n"; break; case "Integer": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Link": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:link.typolink parameter="{' . $datafield . '.' . $fieldKey . '}">{' . $datafield . '.' . $fieldKey . '}</f:link.typolink><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Radio": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}"> <f:case value="1">Value is: 1</f:case> <f:case value="2">Value is: 2</f:case> <f:case value="3">Value is: 3</f:case> </f:switch><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Richtext": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.html parseFuncTSPath="lib.parseFunc_RTE">{' . $datafield . '.' . $fieldKey . '}</f:format.html><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Select": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:switch expression="{' . $datafield . '.' . $fieldKey . '}"> <f:case value="1">Value is: 1</f:case> <f:case value="2">Value is: 2</f:case> <f:case value="3">Value is: 3</f:case> </f:switch><br />' . "\n"; $html .= "</f:if>\n\n"; break; case "String": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '{' . $datafield . '.' . $fieldKey . '}<br />' . "\n"; $html .= "</f:if>\n\n"; break; case "Text": $html .= '<f:if condition="{' . $datafield . '.' . $fieldKey . '}">' . "\n"; $html .= '<f:format.nl2br>{' . $datafield . '.' . $fieldKey . '}</f:format.nl2br><br />' . "\n"; $html .= "</f:if>\n\n"; break; } return $html; }
[ "protected", "function", "generateFieldHtml", "(", "$", "fieldKey", ",", "$", "elementKey", ",", "$", "table", ",", "$", "datafield", "=", "\"data\"", ")", "{", "$", "html", "=", "\"\"", ";", "$", "fieldHelper", "=", "\\", "TYPO3", "\\", "CMS", "\\", "...
Generates HTML for a field @param string $fieldKey @param string $elementKey @param string $table @param string $datafield @return string $html @author Gernot Ploiner <gp@webprofil.at> @author Benjamin Butschell <bb@webprofil.at>
[ "Generates", "HTML", "for", "a", "field" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/CodeGenerator/HtmlCodeGenerator.php#L66-L164
Gernott/mask
Classes/Hooks/PageLayoutViewDrawItem.php
PageLayoutViewDrawItem.preProcess
public function preProcess( \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row ) { $this->settingsService = GeneralUtility::makeInstance(SettingsService::class); $this->extSettings = $this->settingsService->get(); // only render special backend preview if it is a mask element if (substr($row['CType'], 0, 4) === "mask") { $elementKey = substr($row['CType'], 5); # fallback to prevent breaking change $templatePathAndFilename = MaskUtility::getTemplatePath( $this->extSettings, $elementKey, false, MaskUtility::getFileAbsFileName($this->extSettings['backend']) ); if (file_exists($templatePathAndFilename)) { // initialize some things we need $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->inlineHelper = GeneralUtility::makeInstance(InlineHelper::class); $this->storageRepository = $this->objectManager->get(StorageRepository::class); $view = $this->objectManager->get(StandaloneView::class); // Load the backend template $view->setTemplatePathAndFilename($templatePathAndFilename); // if there are paths for layouts and partials set, add them to view if (!empty($this->extSettings["layouts_backend"])) { $layoutRootPath = MaskUtility::getFileAbsFileName($this->extSettings["layouts_backend"]); $view->setLayoutRootPaths(array($layoutRootPath)); } if (!empty($this->extSettings["partials_backend"])) { $partialRootPath = MaskUtility::getFileAbsFileName($this->extSettings["partials_backend"]); $view->setPartialRootPaths(array($partialRootPath)); } // Fetch and assign some useful variables $data = $this->getContentObject($row["uid"]); $element = $this->storageRepository->loadElement("tt_content", $elementKey); $view->assign("row", $row); $view->assign("data", $data); // if the elementLabel contains LLL: then translate it $elementLabel = $element["label"]; if (GeneralUtility::isFirstPartOfStr($elementLabel, 'LLL:')) { $elementLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($elementLabel, "mask"); } // Render everything $content = $view->render(); $editElementUrlParameters = [ 'edit' => [ 'tt_content' => [ $row['uid'] => 'edit' ] ], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') ]; $editElementUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_edit', $editElementUrlParameters); $headerContent = '<strong><a href="' . $editElementUrl . '">' . $elementLabel . '</a></strong><br>'; $itemContent .= '<div style="display:block; padding: 10px 0 4px 0px;border-top: 1px solid #CACACA;margin-top: 6px;" class="content_preview_' . $elementKey . '">'; $itemContent .= $content; $itemContent .= '</div>'; $drawItem = false; } } }
php
public function preProcess( \TYPO3\CMS\Backend\View\PageLayoutView &$parentObject, &$drawItem, &$headerContent, &$itemContent, array &$row ) { $this->settingsService = GeneralUtility::makeInstance(SettingsService::class); $this->extSettings = $this->settingsService->get(); // only render special backend preview if it is a mask element if (substr($row['CType'], 0, 4) === "mask") { $elementKey = substr($row['CType'], 5); # fallback to prevent breaking change $templatePathAndFilename = MaskUtility::getTemplatePath( $this->extSettings, $elementKey, false, MaskUtility::getFileAbsFileName($this->extSettings['backend']) ); if (file_exists($templatePathAndFilename)) { // initialize some things we need $this->objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->inlineHelper = GeneralUtility::makeInstance(InlineHelper::class); $this->storageRepository = $this->objectManager->get(StorageRepository::class); $view = $this->objectManager->get(StandaloneView::class); // Load the backend template $view->setTemplatePathAndFilename($templatePathAndFilename); // if there are paths for layouts and partials set, add them to view if (!empty($this->extSettings["layouts_backend"])) { $layoutRootPath = MaskUtility::getFileAbsFileName($this->extSettings["layouts_backend"]); $view->setLayoutRootPaths(array($layoutRootPath)); } if (!empty($this->extSettings["partials_backend"])) { $partialRootPath = MaskUtility::getFileAbsFileName($this->extSettings["partials_backend"]); $view->setPartialRootPaths(array($partialRootPath)); } // Fetch and assign some useful variables $data = $this->getContentObject($row["uid"]); $element = $this->storageRepository->loadElement("tt_content", $elementKey); $view->assign("row", $row); $view->assign("data", $data); // if the elementLabel contains LLL: then translate it $elementLabel = $element["label"]; if (GeneralUtility::isFirstPartOfStr($elementLabel, 'LLL:')) { $elementLabel = \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate($elementLabel, "mask"); } // Render everything $content = $view->render(); $editElementUrlParameters = [ 'edit' => [ 'tt_content' => [ $row['uid'] => 'edit' ] ], 'returnUrl' => GeneralUtility::getIndpEnv('REQUEST_URI') ]; $editElementUrl = \TYPO3\CMS\Backend\Utility\BackendUtility::getModuleUrl('record_edit', $editElementUrlParameters); $headerContent = '<strong><a href="' . $editElementUrl . '">' . $elementLabel . '</a></strong><br>'; $itemContent .= '<div style="display:block; padding: 10px 0 4px 0px;border-top: 1px solid #CACACA;margin-top: 6px;" class="content_preview_' . $elementKey . '">'; $itemContent .= $content; $itemContent .= '</div>'; $drawItem = false; } } }
[ "public", "function", "preProcess", "(", "\\", "TYPO3", "\\", "CMS", "\\", "Backend", "\\", "View", "\\", "PageLayoutView", "&", "$", "parentObject", ",", "&", "$", "drawItem", ",", "&", "$", "headerContent", ",", "&", "$", "itemContent", ",", "array", "...
Preprocesses the preview rendering of a content element. @param \TYPO3\CMS\Backend\View\PageLayoutView $parentObject Calling parent object @param boolean $drawItem Whether to draw the item using the default functionalities @param string $headerContent Header content @param string $itemContent Item content @param array $row Record row of tt_content @return void
[ "Preprocesses", "the", "preview", "rendering", "of", "a", "content", "element", "." ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Hooks/PageLayoutViewDrawItem.php#L90-L163
Gernott/mask
Classes/Hooks/PageLayoutViewDrawItem.php
PageLayoutViewDrawItem.getContentObject
protected function getContentObject($uid) { $contentTable = 'tt_content'; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($contentTable); $queryBuilder ->select('*') ->from($contentTable) ->where($queryBuilder->expr()->eq('uid', $uid)); $queryBuilder->getRestrictions()->removeAll(); $data = $queryBuilder->execute()->fetch(); $this->inlineHelper->addFilesToData($data, 'tt_content'); $this->inlineHelper->addIrreToData($data); return $data; }
php
protected function getContentObject($uid) { $contentTable = 'tt_content'; $queryBuilder = GeneralUtility::makeInstance(ConnectionPool::class)->getQueryBuilderForTable($contentTable); $queryBuilder ->select('*') ->from($contentTable) ->where($queryBuilder->expr()->eq('uid', $uid)); $queryBuilder->getRestrictions()->removeAll(); $data = $queryBuilder->execute()->fetch(); $this->inlineHelper->addFilesToData($data, 'tt_content'); $this->inlineHelper->addIrreToData($data); return $data; }
[ "protected", "function", "getContentObject", "(", "$", "uid", ")", "{", "$", "contentTable", "=", "'tt_content'", ";", "$", "queryBuilder", "=", "GeneralUtility", "::", "makeInstance", "(", "ConnectionPool", "::", "class", ")", "->", "getQueryBuilderForTable", "("...
Returns an array with properties of content element with given uid @param int $uid of content element to get @return array with all properties of given content element uid
[ "Returns", "an", "array", "with", "properties", "of", "content", "element", "with", "given", "uid" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Hooks/PageLayoutViewDrawItem.php#L171-L186
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.isEvalValueSet
public function isEvalValueSet($fieldKey, $evalValue, $type = "tt_content") { $storage = $this->storageRepository->load(); $found = false; if ($storage[$type]["tca"][$fieldKey]["config"]["eval"] != "") { $evals = explode(",", $storage[$type]["tca"][$fieldKey]["config"]["eval"]); foreach ($evals as $index => $eval) { $evals[$index] = strtolower($eval); } $found = array_search(strtolower($evalValue), $evals) !== false; } return $found; }
php
public function isEvalValueSet($fieldKey, $evalValue, $type = "tt_content") { $storage = $this->storageRepository->load(); $found = false; if ($storage[$type]["tca"][$fieldKey]["config"]["eval"] != "") { $evals = explode(",", $storage[$type]["tca"][$fieldKey]["config"]["eval"]); foreach ($evals as $index => $eval) { $evals[$index] = strtolower($eval); } $found = array_search(strtolower($evalValue), $evals) !== false; } return $found; }
[ "public", "function", "isEvalValueSet", "(", "$", "fieldKey", ",", "$", "evalValue", ",", "$", "type", "=", "\"tt_content\"", ")", "{", "$", "storage", "=", "$", "this", "->", "storageRepository", "->", "load", "(", ")", ";", "$", "found", "=", "false", ...
Checks if a $evalValue is set in a field @param string $fieldKey TCA Type @param string $evalValue value to search for @param string $type elementtype @return boolean $evalValue is set @author Benjamin Butschell <bb@webprofil.at>
[ "Checks", "if", "a", "$evalValue", "is", "set", "in", "a", "field" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L69-L81
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.getRteTransformMode
public function getRteTransformMode($fieldKey, $type = "tt_content") { $storage = $this->storageRepository->load(); $transformMode = ""; $matches = array(); if ($storage[$type]["tca"][$fieldKey]["defaultExtras"] != "") { $re = "/(rte_transform\\[([a-z=_]+)\\])/"; preg_match($re, $storage[$type]["tca"][$fieldKey]["defaultExtras"], $matches); $transformMode = end($matches); } return $transformMode; }
php
public function getRteTransformMode($fieldKey, $type = "tt_content") { $storage = $this->storageRepository->load(); $transformMode = ""; $matches = array(); if ($storage[$type]["tca"][$fieldKey]["defaultExtras"] != "") { $re = "/(rte_transform\\[([a-z=_]+)\\])/"; preg_match($re, $storage[$type]["tca"][$fieldKey]["defaultExtras"], $matches); $transformMode = end($matches); } return $transformMode; }
[ "public", "function", "getRteTransformMode", "(", "$", "fieldKey", ",", "$", "type", "=", "\"tt_content\"", ")", "{", "$", "storage", "=", "$", "this", "->", "storageRepository", "->", "load", "(", ")", ";", "$", "transformMode", "=", "\"\"", ";", "$", "...
Returns the rte_transform properties @param string $fieldKey TCA Type @param string $type elementtype @return string $rte_transform @author Benjamin Butschell <bb@webprofil.at>
[ "Returns", "the", "rte_transform", "properties" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L91-L102
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.getJsOpenParamValue
public function getJsOpenParamValue($fieldKey, $property, $type = 'tt_content') { $storage = $this->storageRepository->load(); $value = null; $windowOpenParameters = $storage[$type]['tca'][$fieldKey]['config']['fieldControl']['linkPopup']['options']['windowOpenParameters']; if ($windowOpenParameters != '') { $properties = explode(',', $windowOpenParameters); foreach ($properties as $setProperty) { $keyPair = explode('=', $setProperty); if ($property == $keyPair[0]) { $value = $keyPair[1]; break; } } } // if nothing was found, set the default values if ($value == null) { switch ($property) { case 'height': $value = 300; break; case 'width': $value = 500; break; case 'status': $value = 0; break; case 'menubar': $value = 0; break; case 'scrollbars': $value = 1; break; default: $value = null; } } return $value; }
php
public function getJsOpenParamValue($fieldKey, $property, $type = 'tt_content') { $storage = $this->storageRepository->load(); $value = null; $windowOpenParameters = $storage[$type]['tca'][$fieldKey]['config']['fieldControl']['linkPopup']['options']['windowOpenParameters']; if ($windowOpenParameters != '') { $properties = explode(',', $windowOpenParameters); foreach ($properties as $setProperty) { $keyPair = explode('=', $setProperty); if ($property == $keyPair[0]) { $value = $keyPair[1]; break; } } } // if nothing was found, set the default values if ($value == null) { switch ($property) { case 'height': $value = 300; break; case 'width': $value = 500; break; case 'status': $value = 0; break; case 'menubar': $value = 0; break; case 'scrollbars': $value = 1; break; default: $value = null; } } return $value; }
[ "public", "function", "getJsOpenParamValue", "(", "$", "fieldKey", ",", "$", "property", ",", "$", "type", "=", "'tt_content'", ")", "{", "$", "storage", "=", "$", "this", "->", "storageRepository", "->", "load", "(", ")", ";", "$", "value", "=", "null",...
Returns value for jsopenparams property @param string $fieldKey TCA Type @param string $property value to search for @param string $type elementtype @return boolean $evalValue is set @author Benjamin Butschell <bb@webprofil.at>
[ "Returns", "value", "for", "jsopenparams", "property" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L113-L152
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.isBlindLinkOptionSet
public function isBlindLinkOptionSet($fieldKey, $evalValue, $type = 'tt_content') { $storage = $this->storageRepository->load(); $found = false; $blindLinkOptions = $storage[$type]['tca'][$fieldKey]['config']['fieldControl']['linkPopup']['options']['blindLinkOptions']; if ($blindLinkOptions != '') { $evals = explode(',', $blindLinkOptions); $found = \in_array(strtolower($evalValue), $evals, true); } return $found; }
php
public function isBlindLinkOptionSet($fieldKey, $evalValue, $type = 'tt_content') { $storage = $this->storageRepository->load(); $found = false; $blindLinkOptions = $storage[$type]['tca'][$fieldKey]['config']['fieldControl']['linkPopup']['options']['blindLinkOptions']; if ($blindLinkOptions != '') { $evals = explode(',', $blindLinkOptions); $found = \in_array(strtolower($evalValue), $evals, true); } return $found; }
[ "public", "function", "isBlindLinkOptionSet", "(", "$", "fieldKey", ",", "$", "evalValue", ",", "$", "type", "=", "'tt_content'", ")", "{", "$", "storage", "=", "$", "this", "->", "storageRepository", "->", "load", "(", ")", ";", "$", "found", "=", "fals...
Checks if a $evalValue is set in a field @param string $fieldKey TCA Type @param string $evalValue value to search for @param string $type elementtype @return boolean $evalValue is set @author Benjamin Butschell <bb@webprofil.at>
[ "Checks", "if", "a", "$evalValue", "is", "set", "in", "a", "field" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L163-L173
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.replaceKey
public function replaceKey($data, $replace_key, $key = "--key--") { foreach ($data as $elem_key => $elem) { if (is_array($elem)) { $data[$elem_key] = $this->replaceKey($elem, $replace_key); } else { if ($data[$elem_key] == $key) { $data[$elem_key] = $replace_key; } } } return $data; }
php
public function replaceKey($data, $replace_key, $key = "--key--") { foreach ($data as $elem_key => $elem) { if (is_array($elem)) { $data[$elem_key] = $this->replaceKey($elem, $replace_key); } else { if ($data[$elem_key] == $key) { $data[$elem_key] = $replace_key; } } } return $data; }
[ "public", "function", "replaceKey", "(", "$", "data", ",", "$", "replace_key", ",", "$", "key", "=", "\"--key--\"", ")", "{", "foreach", "(", "$", "data", "as", "$", "elem_key", "=>", "$", "elem", ")", "{", "if", "(", "is_array", "(", "$", "elem", ...
replace keys @author Gernot Ploiner <gp@webprofil.at> @return array
[ "replace", "keys" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L181-L193
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.getFirstNoneTabField
public function getFirstNoneTabField($fields) { if (count($fields)) { $potentialFirst = $fields[0]; if (strpos($potentialFirst, "--div--") !== false) { unset($fields[0]); return $this->getFirstNoneTabField($fields); } else { return $potentialFirst; } } else { return ""; } }
php
public function getFirstNoneTabField($fields) { if (count($fields)) { $potentialFirst = $fields[0]; if (strpos($potentialFirst, "--div--") !== false) { unset($fields[0]); return $this->getFirstNoneTabField($fields); } else { return $potentialFirst; } } else { return ""; } }
[ "public", "function", "getFirstNoneTabField", "(", "$", "fields", ")", "{", "if", "(", "count", "(", "$", "fields", ")", ")", "{", "$", "potentialFirst", "=", "$", "fields", "[", "0", "]", ";", "if", "(", "strpos", "(", "$", "potentialFirst", ",", "\...
Searches an array of strings and returns the first string, that is not a tab @param array $fields @return $string
[ "Searches", "an", "array", "of", "strings", "and", "returns", "the", "first", "string", "that", "is", "not", "a", "tab" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L200-L213
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.removeBlankOptions
public function removeBlankOptions($haystack) { foreach ($haystack as $key => $value) { if (is_array($value)) { $haystack[$key] = $this->removeBlankOptions($haystack[$key]); } if ((is_array($haystack[$key]) && empty($haystack[$key])) || (is_string($haystack[$key]) && !strlen($haystack[$key]))) { unset($haystack[$key]); } } return $haystack; }
php
public function removeBlankOptions($haystack) { foreach ($haystack as $key => $value) { if (is_array($value)) { $haystack[$key] = $this->removeBlankOptions($haystack[$key]); } if ((is_array($haystack[$key]) && empty($haystack[$key])) || (is_string($haystack[$key]) && !strlen($haystack[$key]))) { unset($haystack[$key]); } } return $haystack; }
[ "public", "function", "removeBlankOptions", "(", "$", "haystack", ")", "{", "foreach", "(", "$", "haystack", "as", "$", "key", "=>", "$", "value", ")", "{", "if", "(", "is_array", "(", "$", "value", ")", ")", "{", "$", "haystack", "[", "$", "key", ...
Removes all the blank options from the tca @param array $haystack @return array
[ "Removes", "all", "the", "blank", "options", "from", "the", "tca" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L220-L231
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.getTemplatePath
public static function getTemplatePath( $settings, $elementKey, $onlyTemplateName = false, $path = null ): string { if (!$path) { $path = self::getFileAbsFileName(rtrim($settings['content'], '/') . '/'); } $fileExtension = '.html'; // check if an html file with underscores exist if (file_exists($path . CoreUtility::underscoredToUpperCamelCase($elementKey) . $fileExtension) ) { $fileName = CoreUtility::underscoredToUpperCamelCase($elementKey); } else { if (file_exists($path . ucfirst($elementKey) . $fileExtension) ) { $fileName = ucfirst($elementKey); } else { if (file_exists($path . $elementKey . $fileExtension)) { $fileName = $elementKey; } else { $fileName = CoreUtility::underscoredToUpperCamelCase($elementKey); } } } if ($onlyTemplateName) { return $fileName . $fileExtension; } return $path . $fileName . $fileExtension; }
php
public static function getTemplatePath( $settings, $elementKey, $onlyTemplateName = false, $path = null ): string { if (!$path) { $path = self::getFileAbsFileName(rtrim($settings['content'], '/') . '/'); } $fileExtension = '.html'; // check if an html file with underscores exist if (file_exists($path . CoreUtility::underscoredToUpperCamelCase($elementKey) . $fileExtension) ) { $fileName = CoreUtility::underscoredToUpperCamelCase($elementKey); } else { if (file_exists($path . ucfirst($elementKey) . $fileExtension) ) { $fileName = ucfirst($elementKey); } else { if (file_exists($path . $elementKey . $fileExtension)) { $fileName = $elementKey; } else { $fileName = CoreUtility::underscoredToUpperCamelCase($elementKey); } } } if ($onlyTemplateName) { return $fileName . $fileExtension; } return $path . $fileName . $fileExtension; }
[ "public", "static", "function", "getTemplatePath", "(", "$", "settings", ",", "$", "elementKey", ",", "$", "onlyTemplateName", "=", "false", ",", "$", "path", "=", "null", ")", ":", "string", "{", "if", "(", "!", "$", "path", ")", "{", "$", "path", "...
Check which template path to return @param $settings @param $elementKey @param bool $onlyTemplateName @param null $path @return string
[ "Check", "which", "template", "path", "to", "return" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L242-L274
Gernott/mask
Classes/Utility/GeneralUtility.php
GeneralUtility.getFileAbsFileName
public static function getFileAbsFileName($filename): string { if ((string)$filename === '') { return ''; } // Extension if (strpos($filename, 'EXT:') === 0) { [$extKey, $local] = explode('/', substr($filename, 4), 2); $filename = ''; if ((string)$extKey !== '' && (string)$local !== '') { $filename = Environment::getPublicPath() . '/typo3conf/ext/' . $extKey . '/' . $local; } } elseif (!CoreUtility::isAbsPath($filename)) { // is relative. Prepended with the public web folder $filename = Environment::getPublicPath() . '/' . $filename; } elseif (!( CoreUtility::isFirstPartOfStr($filename, Environment::getProjectPath()) || CoreUtility::isFirstPartOfStr($filename, Environment::getPublicPath()) )) { // absolute, but set to blank if not allowed $filename = ''; } if ((string)$filename !== '' && CoreUtility::validPathStr($filename)) { // checks backpath. return $filename; } return ''; }
php
public static function getFileAbsFileName($filename): string { if ((string)$filename === '') { return ''; } // Extension if (strpos($filename, 'EXT:') === 0) { [$extKey, $local] = explode('/', substr($filename, 4), 2); $filename = ''; if ((string)$extKey !== '' && (string)$local !== '') { $filename = Environment::getPublicPath() . '/typo3conf/ext/' . $extKey . '/' . $local; } } elseif (!CoreUtility::isAbsPath($filename)) { // is relative. Prepended with the public web folder $filename = Environment::getPublicPath() . '/' . $filename; } elseif (!( CoreUtility::isFirstPartOfStr($filename, Environment::getProjectPath()) || CoreUtility::isFirstPartOfStr($filename, Environment::getPublicPath()) )) { // absolute, but set to blank if not allowed $filename = ''; } if ((string)$filename !== '' && CoreUtility::validPathStr($filename)) { // checks backpath. return $filename; } return ''; }
[ "public", "static", "function", "getFileAbsFileName", "(", "$", "filename", ")", ":", "string", "{", "if", "(", "(", "string", ")", "$", "filename", "===", "''", ")", "{", "return", "''", ";", "}", "// Extension", "if", "(", "strpos", "(", "$", "filena...
Returns the absolute filename of a relative reference, resolves the "EXT:" prefix (way of referring to files inside extensions) and checks that the file is inside the TYPO3's base folder and implies a check with \TYPO3\CMS\Core\Utility\GeneralUtility::validPathStr(). "EXT:" prefix is also replaced if the extension is not installed @param string $filename The input filename/filepath to evaluate @return string Returns the absolute filename of $filename if valid, otherwise blank string.
[ "Returns", "the", "absolute", "filename", "of", "a", "relative", "reference", "resolves", "the", "EXT", ":", "prefix", "(", "way", "of", "referring", "to", "files", "inside", "extensions", ")", "and", "checks", "that", "the", "file", "is", "inside", "the", ...
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Utility/GeneralUtility.php#L287-L314
Gernott/mask
Classes/ViewHelpers/FormTypeViewHelper.php
FormTypeViewHelper.render
public function render() { $elementKey = $this->arguments['elementKey']; $fieldKey = $this->arguments['fieldKey']; $type = $this->arguments['type']; $this->fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $formType = $this->fieldHelper->getFormType($fieldKey, $elementKey, $type); return $formType; }
php
public function render() { $elementKey = $this->arguments['elementKey']; $fieldKey = $this->arguments['fieldKey']; $type = $this->arguments['type']; $this->fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $formType = $this->fieldHelper->getFormType($fieldKey, $elementKey, $type); return $formType; }
[ "public", "function", "render", "(", ")", "{", "$", "elementKey", "=", "$", "this", "->", "arguments", "[", "'elementKey'", "]", ";", "$", "fieldKey", "=", "$", "this", "->", "arguments", "[", "'fieldKey'", "]", ";", "$", "type", "=", "$", "this", "-...
Returns the label of a field in an element @return string formType @author Benjamin Butschell bb@webprofil.at>
[ "Returns", "the", "label", "of", "a", "field", "in", "an", "element" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/ViewHelpers/FormTypeViewHelper.php#L40-L49
Gernott/mask
Classes/ItemsProcFuncs/ColPosList.php
ColPosList.itemsProcFunc
public function itemsProcFunc(&$params) { // if this tt_content element is inline element of mask if ($params["row"]["colPos"] == $this->colPos) { // only allow mask nested element column $params["items"] = array( array( \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('mask_content_colpos', 'mask'), $this->colPos, null, null ) ); } else { // if it is not inline tt_content element // and if other itemsProcFunc from other extension was available (e.g. gridelements), // then call it now and let it render the items if (!empty($params["config"]["m_itemsProcFunc"])) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($params["config"]["m_itemsProcFunc"], $params, $this); } } }
php
public function itemsProcFunc(&$params) { // if this tt_content element is inline element of mask if ($params["row"]["colPos"] == $this->colPos) { // only allow mask nested element column $params["items"] = array( array( \TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('mask_content_colpos', 'mask'), $this->colPos, null, null ) ); } else { // if it is not inline tt_content element // and if other itemsProcFunc from other extension was available (e.g. gridelements), // then call it now and let it render the items if (!empty($params["config"]["m_itemsProcFunc"])) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($params["config"]["m_itemsProcFunc"], $params, $this); } } }
[ "public", "function", "itemsProcFunc", "(", "&", "$", "params", ")", "{", "// if this tt_content element is inline element of mask", "if", "(", "$", "params", "[", "\"row\"", "]", "[", "\"colPos\"", "]", "==", "$", "this", "->", "colPos", ")", "{", "// only allo...
Render the allowed colPos for nested content elements @param array $params
[ "Render", "the", "allowed", "colPos", "for", "nested", "content", "elements" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/ItemsProcFuncs/ColPosList.php#L40-L61
Gernott/mask
Classes/Imaging/IconProvider/ContentElementIconProvider.php
ContentElementIconProvider.generateMarkup
protected function generateMarkup(Icon $icon, array $options) { $previewIconAvailable = $this->isPreviewIconAvailable($options['contentElementKey']); $fontAwesomeKeyAvailable = $this->isFontAwesomeKeyAvailable($this->contentElement); // decide what kind of icon to render if ($fontAwesomeKeyAvailable) { $color = $this->getColor($this->contentElement); if ($color) { $styles[] = "color: #" . $color; } if (count($styles)) { $markup = '<span class="icon-unify" style="' . implode("; ", $styles) . '"><i class="fa fa-' . htmlspecialchars($this->getFontAwesomeKey($this->contentElement)) . '"></i></span>'; } else { $markup = '<span class="icon-unify" ><i class="fa fa-' . htmlspecialchars($this->getFontAwesomeKey($this->contentElement)) . '"></i></span>'; } } else { if ($previewIconAvailable) { $markup = '<img src="' . PathUtility::getAbsoluteWebPath(PATH_site . ltrim($this->getPreviewIconPath($options['contentElementKey']), '/')) . '" alt="' . $this->contentElement["label"] . '" title="' . $this->contentElement["label"] . '"/>'; } else { $color = $this->getColor($this->contentElement); if ($color) { $styles[] = "background-color: #" . $color; } $styles[] = "color: #fff"; $markup = '<span class="icon-unify mask-default-icon" style="' . implode("; ", $styles) . '">' . mb_substr($this->contentElement["label"], 0, 1) . '</span>'; } } return $markup; }
php
protected function generateMarkup(Icon $icon, array $options) { $previewIconAvailable = $this->isPreviewIconAvailable($options['contentElementKey']); $fontAwesomeKeyAvailable = $this->isFontAwesomeKeyAvailable($this->contentElement); // decide what kind of icon to render if ($fontAwesomeKeyAvailable) { $color = $this->getColor($this->contentElement); if ($color) { $styles[] = "color: #" . $color; } if (count($styles)) { $markup = '<span class="icon-unify" style="' . implode("; ", $styles) . '"><i class="fa fa-' . htmlspecialchars($this->getFontAwesomeKey($this->contentElement)) . '"></i></span>'; } else { $markup = '<span class="icon-unify" ><i class="fa fa-' . htmlspecialchars($this->getFontAwesomeKey($this->contentElement)) . '"></i></span>'; } } else { if ($previewIconAvailable) { $markup = '<img src="' . PathUtility::getAbsoluteWebPath(PATH_site . ltrim($this->getPreviewIconPath($options['contentElementKey']), '/')) . '" alt="' . $this->contentElement["label"] . '" title="' . $this->contentElement["label"] . '"/>'; } else { $color = $this->getColor($this->contentElement); if ($color) { $styles[] = "background-color: #" . $color; } $styles[] = "color: #fff"; $markup = '<span class="icon-unify mask-default-icon" style="' . implode("; ", $styles) . '">' . mb_substr($this->contentElement["label"], 0, 1) . '</span>'; } } return $markup; }
[ "protected", "function", "generateMarkup", "(", "Icon", "$", "icon", ",", "array", "$", "options", ")", "{", "$", "previewIconAvailable", "=", "$", "this", "->", "isPreviewIconAvailable", "(", "$", "options", "[", "'contentElementKey'", "]", ")", ";", "$", "...
Renders the actual icon @param Icon $icon @param array $options @return string @throws \InvalidArgumentException @author Benjamin Butschell <bb@webprofil.at>
[ "Renders", "the", "actual", "icon" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Imaging/IconProvider/ContentElementIconProvider.php#L96-L132
Gernott/mask
Classes/Fluid/FluidTemplateContentObject.php
FluidTemplateContentObject.getContentObjectVariables
protected function getContentObjectVariables(array $conf = array()) { // Call Parent Function to maintain core functions $variables = parent::getContentObjectVariables($conf); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->inlineHelper = $objectManager->get(InlineHelper::class); // Make some enhancements to data $data = $variables['data']; $this->inlineHelper->addFilesToData($data, "pages"); $this->inlineHelper->addIrreToData($data, "pages"); $variables['data'] = $data; return $variables; }
php
protected function getContentObjectVariables(array $conf = array()) { // Call Parent Function to maintain core functions $variables = parent::getContentObjectVariables($conf); $objectManager = GeneralUtility::makeInstance(ObjectManager::class); $this->inlineHelper = $objectManager->get(InlineHelper::class); // Make some enhancements to data $data = $variables['data']; $this->inlineHelper->addFilesToData($data, "pages"); $this->inlineHelper->addIrreToData($data, "pages"); $variables['data'] = $data; return $variables; }
[ "protected", "function", "getContentObjectVariables", "(", "array", "$", "conf", "=", "array", "(", ")", ")", "{", "// Call Parent Function to maintain core functions", "$", "variables", "=", "parent", "::", "getContentObjectVariables", "(", "$", "conf", ")", ";", "...
Change variables for view @param array $conf Configuration @author Benjamin Butschell <bb@webprofil.at> @return void
[ "Change", "variables", "for", "view" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Fluid/FluidTemplateContentObject.php#L64-L79
Gernott/mask
Classes/ItemsProcFuncs/CTypeList.php
CTypeList.itemsProcFunc
public function itemsProcFunc(&$params) { // if this tt_content element is inline element of mask if ($params["row"]["colPos"] == $this->colPos) { $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $this->storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository'); if (isset($_REQUEST["ajax"]["context"])) { $ajaxContext = json_decode($_REQUEST["ajax"]["context"]); $fieldKey = str_replace("_parent", "", $ajaxContext->config->foreign_field); } else { $fields = $params["row"]; foreach ($fields as $key => $field) { // search for the parent field, to get the key of mask field this content element belongs to if ($this->startsWith($key, "tx_mask_") && $this->endsWith($key, "_parent") && $field > 0) { // if a parent field was found, that is filled with a uid, extract the mask field name from it $fieldKey = str_replace("_parent", "", $key); // if one parent field was found, don't continue search, there can only be one parent break; } } } // load the json configuration of this field $table = $fieldHelper->getFieldType($fieldKey); $fieldConfiguration = $this->storageRepository->loadField($table, $fieldKey); // if there is a restriction of cTypes specified if (is_array($fieldConfiguration["cTypes"])) { // prepare array of allowed cTypes, with cTypes as keys $cTypes = array_flip($fieldConfiguration["cTypes"]); // and check each item if it is allowed. if not, unset it foreach ($params["items"] as $itemKey => $item) { if (!isset($cTypes[$item[1]])) { unset($params["items"][$itemKey]); } } } } else { // if it is not inline tt_content element // and if other itemsProcFunc from other extension was available (e.g. gridelements), // then call it now and let it render the items if (!empty($params["config"]["m_itemsProcFunc"])) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($params["config"]["m_itemsProcFunc"], $params, $this); } } }
php
public function itemsProcFunc(&$params) { // if this tt_content element is inline element of mask if ($params["row"]["colPos"] == $this->colPos) { $fieldHelper = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Helper\\FieldHelper'); $this->storageRepository = \TYPO3\CMS\Core\Utility\GeneralUtility::makeInstance('MASK\\Mask\\Domain\\Repository\\StorageRepository'); if (isset($_REQUEST["ajax"]["context"])) { $ajaxContext = json_decode($_REQUEST["ajax"]["context"]); $fieldKey = str_replace("_parent", "", $ajaxContext->config->foreign_field); } else { $fields = $params["row"]; foreach ($fields as $key => $field) { // search for the parent field, to get the key of mask field this content element belongs to if ($this->startsWith($key, "tx_mask_") && $this->endsWith($key, "_parent") && $field > 0) { // if a parent field was found, that is filled with a uid, extract the mask field name from it $fieldKey = str_replace("_parent", "", $key); // if one parent field was found, don't continue search, there can only be one parent break; } } } // load the json configuration of this field $table = $fieldHelper->getFieldType($fieldKey); $fieldConfiguration = $this->storageRepository->loadField($table, $fieldKey); // if there is a restriction of cTypes specified if (is_array($fieldConfiguration["cTypes"])) { // prepare array of allowed cTypes, with cTypes as keys $cTypes = array_flip($fieldConfiguration["cTypes"]); // and check each item if it is allowed. if not, unset it foreach ($params["items"] as $itemKey => $item) { if (!isset($cTypes[$item[1]])) { unset($params["items"][$itemKey]); } } } } else { // if it is not inline tt_content element // and if other itemsProcFunc from other extension was available (e.g. gridelements), // then call it now and let it render the items if (!empty($params["config"]["m_itemsProcFunc"])) { \TYPO3\CMS\Core\Utility\GeneralUtility::callUserFunction($params["config"]["m_itemsProcFunc"], $params, $this); } } }
[ "public", "function", "itemsProcFunc", "(", "&", "$", "params", ")", "{", "// if this tt_content element is inline element of mask", "if", "(", "$", "params", "[", "\"row\"", "]", "[", "\"colPos\"", "]", "==", "$", "this", "->", "colPos", ")", "{", "$", "field...
Render the allowed CTypes for nested content elements @param array $params
[ "Render", "the", "allowed", "CTypes", "for", "nested", "content", "elements" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/ItemsProcFuncs/CTypeList.php#L47-L97
Gernott/mask
Classes/Controller/WizardContentController.php
WizardContentController.listAction
public function listAction() { $this->checkFolders(); $this->view->assign('missingFolders', $this->missingFolders); $this->view->assign('storages', $this->storageRepository->load()); }
php
public function listAction() { $this->checkFolders(); $this->view->assign('missingFolders', $this->missingFolders); $this->view->assign('storages', $this->storageRepository->load()); }
[ "public", "function", "listAction", "(", ")", "{", "$", "this", "->", "checkFolders", "(", ")", ";", "$", "this", "->", "view", "->", "assign", "(", "'missingFolders'", ",", "$", "this", "->", "missingFolders", ")", ";", "$", "this", "->", "view", "->"...
action list @return void
[ "action", "list" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardContentController.php#L64-L69
Gernott/mask
Classes/Controller/WizardContentController.php
WizardContentController.createAction
public function createAction($storage) { $this->storageRepository->add($storage); $this->generateAction(); $html = $this->htmlCodeGenerator->generateHtml($storage["elements"]["key"], 'tt_content'); $this->saveHtml($storage["elements"]["key"], $html); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.newcontentelement', 'mask')); $this->redirectByAction(); }
php
public function createAction($storage) { $this->storageRepository->add($storage); $this->generateAction(); $html = $this->htmlCodeGenerator->generateHtml($storage["elements"]["key"], 'tt_content'); $this->saveHtml($storage["elements"]["key"], $html); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.newcontentelement', 'mask')); $this->redirectByAction(); }
[ "public", "function", "createAction", "(", "$", "storage", ")", "{", "$", "this", "->", "storageRepository", "->", "add", "(", "$", "storage", ")", ";", "$", "this", "->", "generateAction", "(", ")", ";", "$", "html", "=", "$", "this", "->", "htmlCodeG...
action create @param array $storage @return void
[ "action", "create" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardContentController.php#L88-L97
Gernott/mask
Classes/Controller/WizardContentController.php
WizardContentController.editAction
public function editAction($type, $key) { $storage = $this->storageRepository->loadElement($type, $key); $icons = $this->iconRepository->findAll(); $this->prepareStorage($storage); $this->view->assign('storage', $storage); $this->view->assign('icons', $icons); $this->view->assign('editMode', 1); }
php
public function editAction($type, $key) { $storage = $this->storageRepository->loadElement($type, $key); $icons = $this->iconRepository->findAll(); $this->prepareStorage($storage); $this->view->assign('storage', $storage); $this->view->assign('icons', $icons); $this->view->assign('editMode', 1); }
[ "public", "function", "editAction", "(", "$", "type", ",", "$", "key", ")", "{", "$", "storage", "=", "$", "this", "->", "storageRepository", "->", "loadElement", "(", "$", "type", ",", "$", "key", ")", ";", "$", "icons", "=", "$", "this", "->", "i...
action edit @param string $type @param string $key @return void
[ "action", "edit" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardContentController.php#L106-L114
Gernott/mask
Classes/Controller/WizardContentController.php
WizardContentController.deleteAction
public function deleteAction($key, $type) { $this->storageRepository->remove($type, $key); $this->generateAction(); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.deletedcontentelement', 'mask')); $this->redirect('list'); }
php
public function deleteAction($key, $type) { $this->storageRepository->remove($type, $key); $this->generateAction(); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.deletedcontentelement', 'mask')); $this->redirect('list'); }
[ "public", "function", "deleteAction", "(", "$", "key", ",", "$", "type", ")", "{", "$", "this", "->", "storageRepository", "->", "remove", "(", "$", "type", ",", "$", "key", ")", ";", "$", "this", "->", "generateAction", "(", ")", ";", "$", "this", ...
action delete @param string $key @param string $type @return void
[ "action", "delete" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardContentController.php#L140-L147
Gernott/mask
Classes/Controller/WizardContentController.php
WizardContentController.hideAction
public function hideAction($key) { $this->storageRepository->hide("tt_content", $key); $this->generateAction(); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.hiddencontentelement', 'mask')); $this->redirect('list'); }
php
public function hideAction($key) { $this->storageRepository->hide("tt_content", $key); $this->generateAction(); $this->addFlashMessage(\TYPO3\CMS\Extbase\Utility\LocalizationUtility::translate('tx_mask.content.hiddencontentelement', 'mask')); $this->redirect('list'); }
[ "public", "function", "hideAction", "(", "$", "key", ")", "{", "$", "this", "->", "storageRepository", "->", "hide", "(", "\"tt_content\"", ",", "$", "key", ")", ";", "$", "this", "->", "generateAction", "(", ")", ";", "$", "this", "->", "addFlashMessage...
action hide @param string $key @return void
[ "action", "hide" ]
train
https://github.com/Gernott/mask/blob/21fd1814eaff4dfbfed34fbed64369918381c77a/Classes/Controller/WizardContentController.php#L172-L179