49 $this->file_path = $filePath;
60 $this->file_path = $filePath;
71 $this->file_path = $filePath;
111 if ( !file_exists($filePath) ) {
112 throw $this->ef->exception(
Exception\CrawlerException::INVALID_FILE_PATH,$filePath);
114 $content = file_get_contents($filePath);
116 throw $this->ef->exception(
Exception\CrawlerException::FILE_OPENING_FAILED,$filePath);
127 $parser_state = self::PARSER_STATE_OUTSIDE;
129 $yaml_entries =
array();
131 foreach(preg_split(
"/((\r?\n)|(\r\n?))/", $content) as $line){
132 if($parser_state === self::PARSER_STATE_OUTSIDE ){
133 if(preg_match(
'/---/', $line)) {
135 $parser_state = self::PARSER_STATE_ENTRY;
138 if(preg_match(
'/\@return/', $line)) {
139 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_YAML_DESCRIPTION,
140 " in file: ".$this->file_path.
", ".$line);
142 if(preg_match(
'/public function (.*)\(/', $line)) {
143 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_YAML_DESCRIPTION,
144 " in file: ".$this->file_path.
", ".$line);
146 }
else if($parser_state === self::PARSER_STATE_ENTRY){
147 if(!preg_match(
'/(\*$)|(---)/', $line)){
150 if(preg_match(
'/---/', $line)) {
151 $parser_state = self::PARSER_STATE_SEEKING_RETURN;
153 if(preg_match(
'/\@return/', $line)) {
154 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_YAML_DESCRIPTION,
155 " in file: ".$this->file_path.
", ".$line);
157 if(preg_match(
'/public function (.*)\(/', $line)) {
158 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_YAML_DESCRIPTION,
159 " in file: ".$this->file_path.
", ".$line);
161 }
else if($parser_state === self::PARSER_STATE_SEEKING_RETURN) {
162 if(preg_match(
'/\@return/', $line)) {
163 $current_entry .=
"namespace: ".ltrim($this->
purifyYamlLine($line),
'@return');
164 $parser_state = self::PARSER_STATE_SEEKING_FUNCTION_NAME;
166 if(preg_match(
'/---/', $line)) {
167 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_VALID_RETURN_STATEMENT,
168 " in file: ".$this->file_path.
" line ".$current_entry);
170 if(preg_match(
'/public function (.*)\(/', $line)) {
171 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_VALID_RETURN_STATEMENT,
172 " in file: ".$this->file_path.
" line ".$current_entry);
175 if(preg_match(
'/public function (.*)\(/', $line,$matches)) {
176 preg_match(
'/public function (.*)\(/',$line, $matches);
177 $current_entry .=
"function_name: ".$matches[1];
178 $yaml_entries[] = $current_entry;
179 $parser_state = self::PARSER_STATE_OUTSIDE;
181 if(preg_match(
'/---/', $line)) {
182 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITHOUT_FUNCTION,
183 " in file: ".$this->file_path.
" line ".$current_entry);
188 if($parser_state === self::PARSER_STATE_SEEKING_RETURN ){
189 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_VALID_RETURN_STATEMENT,
190 " in file: ".$this->file_path.
" line ".$current_entry);
191 }
else if($parser_state === self::PARSER_STATE_ENTRY){
192 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_YAML_DESCRIPTION,
193 " in file: ".$this->file_path);
194 }
else if($parser_state === self::PARSER_STATE_SEEKING_FUNCTION_NAME){;
195 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITHOUT_FUNCTION,
196 " in file: ".$this->file_path);
198 return $yaml_entries;
206 return str_replace(
"* ",
"", ltrim($line)).PHP_EOL;
218 foreach($yaml_entries as $yaml_entry){
220 $entries[] =
$parser->parse($yaml_entry);
223 throw $this->ef->exception(
Exception\CrawlerException::PARSING_YAML_ENTRY_FAILED,
" file: ".$this->file_path.
"; ".$e);
228 array_walk_recursive($entries,
function(&$item){
242 foreach($entries_array as $entry_data){
256 $entry_data[
'title'] = self::fromCamelCaseToWords($entry_data[
'function_name']);
258 if(!array_key_exists(
"title",$entry_data) || !$entry_data[
'title'] || $entry_data[
'title'] ==
""){
259 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_TITLE_MISSING,
" File: ".$this->file_path);
261 if(!array_key_exists(
"namespace",$entry_data) || !$entry_data[
'namespace'] || $entry_data[
'namespace'] ==
""){
262 throw $this->ef->exception(
Exception\CrawlerException::ENTRY_WITH_NO_VALID_RETURN_STATEMENT,
" File: ".$this->file_path);
265 $entry_data[
'id'] = str_replace(
"\\",
"",
266 str_replace(
"\\ILIAS\\UI\\",
"", str_replace(
"\\ILIAS\\UI\\Component\\",
"",$entry_data[
'namespace'])) )
267 .self::toUpperCamelCase($entry_data[
'title'],
' ');
268 $entry_data[
'abstract'] = preg_match(
"/Factory/",$entry_data[
'namespace']);
269 $entry_data[
'path'] = str_replace(
"/ILIAS",
"src",str_replace(
"\\",
"/",$entry_data[
'namespace']));
274 throw $this->ef->exception(
Exception\CrawlerException::PARSING_YAML_ENTRY_FAILED,
275 " could not convert data to entry, message: '".$e->getMessage().
"' file: ".
$this->file_path);
287 return str_replace($seperator,
'', ucwords($string));
296 return str_replace($seperator,
'', lcfirst(ucwords($string)));
304 return join(preg_split(
'/(?<=[a-z])(?=[A-Z])/x', ucwords($camelCaseString)),
" " );
parseArrayFromString($content)
static toLowerCamelCase($string, $seperator)
const PARSER_STATE_SEEKING_RETURN
parseEntriesFromString($content)
getYamlEntriesFromString($content)
Container storing a list of UI Component Entries, can act as Iterator, countable and is serializable...
getPHPArrayFromYamlArray($yaml_entries)
static fromCamelCaseToWords($camelCaseString)
parseYamlStringArrayFromString($content)
getEntryFromData(array $entry_data)
const PARSER_STATE_OUTSIDE
getEntriesFromArray(array $entries_array)
if($is_dev) echo "Review changes write something in WHATSNEW and and then commit with log PHP_EOL
Stores Information of UI Components parsed from YAML, examples and less files.
getFileContentAsString($filePath)
Create styles array
The data for the language used.
parseYamlStringArrayFromFile($filePath)
Parses information from UI components.
static toUpperCamelCase($string, $seperator)
parseEntriesFromFile($filePath)
const PARSER_STATE_SEEKING_FUNCTION_NAME
__construct()
FactoryCrawler constructor.
parseArrayFromFile($filePath)