src/objects/scanners/Scanner.php
protected function scan($path = '')
		{
			// add folder
			$this->addFolder($path);

			// get elements
			$root       = AbstractScanner::folderize($this->path . $path);
			$els        = array_diff(scandir($root), ['.', '..']);

			// split elements
			$files      = [];
			$folders    = [];
			foreach ($els as $el)
			{
				is_dir($root . $el)
					? array_push($folders, $el)
					: array_push($files, $el);
			}

			// get all controllers
			$controllers = [];
			$ordered = [];
			foreach ($files as $file)
			{
				$abspath = $root . $file;
				if($this->isController($abspath))
				{
					$controller = $this->addController($abspath, $path);
					if ($controller)
					{
						property_exists($controller, 'order') && $controller->order !== 0
							? array_push($ordered, $controller)
							: array_push($controllers, $controller);
					}
				}

			}

			// re-insert ordered controllers
			uasort($ordered, function ($a, $b) { return $a->order - $b->order; });
			foreach($ordered as $c)
			{
				array_splice($controllers, $c->order - 1, 0, [$c]);
			}

			// add controllers
			$this->controllers = array_merge($this->controllers, array_values($controllers));

			// folders
			foreach ($folders as $folder)
			{
				$relpath = $path . $folder;
				$this->scan($relpath . '/');
			}
		}
protected function scan($path = '')
		{
			// add folder
			$this->addFolder($path);

			// get elements
			$root       = AbstractScanner::folderize($this->path . $path);
			$els        = array_diff(scandir($root), ['.', '..']);

			// split elements
			$files      = [];
			$folders    = [];
			foreach ($els as $el)
			{
				is_dir($root . $el)
					? array_push($folders, $el)
					: array_push($files, $el);
			}

			// get all controllers
			$controllers = [];
			$ordered = [];
			foreach ($files as $file)
			{
				$abspath = $root . $file;
				if($this->isController($abspath))
				{
					$controller = $this->addController($abspath, $path);
					if ($controller)
					{
						property_exists($controller, 'order') && $controller->order !== 0
							? array_push($ordered, $controller)
							: array_push($controllers, $controller);
					}
				}

			}

			// re-insert ordered controllers
			uasort($ordered, function ($a, $b) { return $a->order - $b->order; });
			foreach($ordered as $c)
			{
				array_splice($controllers, $c->order - 1, 0, [$c]);
			}

			// add controllers
			$this->controllers = array_merge($this->controllers, array_values($controllers));

			// folders
			foreach ($folders as $folder)
			{
				$relpath = $path . $folder;
				$this->scan($relpath . '/');
			}
		}
protected function scan ( $ path = '' ) { // add folder $ this -> addFolder ( $ path ) ; // get elements $ root = AbstractScanner :: folderize ( $ this -> path . $ path ) ; $ els = array_diff ( scandir ( $ root ) , [ '.' , '..' ] ) ; // split elements $ files = [ ] ; $ folders = [ ] ; foreach ( $ els as $ el ) { is_dir ( $ root . $ el ) ? array_push ( $ folders , $ el ) : array_push ( $ files , $ el ) ; } // get all controllers $ controllers = [ ] ; $ ordered = [ ] ; foreach ( $ files as $ file ) { $ abspath = $ root . $ file ; if ( $ this -> isController ( $ abspath ) ) { $ controller = $ this -> addController ( $ abspath , $ path ) ; if ( $ controller ) { property_exists ( $ controller , 'order' ) && $ controller -> order !== 0 ? array_push ( $ ordered , $ controller ) : array_push ( $ controllers , $ controller ) ; } } } // re-insert ordered controllers uasort ( $ ordered , function ( $ a , $ b ) { return $ a -> order - $ b -> order ; } ) ; foreach ( $ ordered as $ c ) { array_splice ( $ controllers , $ c -> order - 1 , 0 , [ $ c ] ) ; } // add controllers $ this -> controllers = array_merge ( $ this -> controllers , array_values ( $ controllers ) ) ; // folders foreach ( $ folders as $ folder ) { $ relpath = $ path . $ folder ; $ this -> scan ( $ relpath . '/' ) ; } }
Recursively finds all controllers and folders

Sets controllers and folders elements as they are found

@param   string  $path   The sketchpad controllers path-relative path to the folder, i.e. "foo/bar/"
Recursively finds all controllers and folders