public function find($extension = null, $file = null)
	{
		// Exclude certain thiings from our search
		$exclude = array(".", "..");
		$files   = [];
		$ext     = '';

		foreach ($this->searchPaths as $path)
		{
			if (!is_dir($path . DS . 'migrations'))
			{
				continue;
			}
			$found = array_diff(scandir($path . DS . 'migrations'), $exclude);

			foreach ($found as $f)
			{
				$files[$path . DS . 'migrations' . DS . $f] = $f;
			}
		}

		asort($files);

		if (!is_null($file))
		{
			if (in_array($file, $files))
			{
				$this->files[] = array_search($file, $files);
				return true;
			}
			else
			{
				$this->log("Provided file ({$file}) could not be found.", 'error');
				return false;
			}
		}

		if (!is_null($extension))
		{
			$parts = explode('_', $extension);
			foreach ($parts as $part)
			{
				$ext .= ucfirst($part);
			}
		}

		foreach ($files as $path => $file)
		{
			// Make sure they have a php extension and proper filename format
			if (preg_match('/^Migration[0-9]{14}[[:alnum:]]+\.php$/', $file))
			{
				// If an extension was provided...match against it...
				if (empty($ext) || (!empty($ext) && preg_match('/Migration[0-9]{14}'.$ext.'\.php/', $file)))
				{
					$this->files[] = $path;
				}
			}
		}

		return true;
	}
public function find($extension = null, $file = null)
	{
		// Exclude certain thiings from our search
		$exclude = array(".", "..");
		$files   = [];
		$ext     = '';

		foreach ($this->searchPaths as $path)
		{
			if (!is_dir($path . DS . 'migrations'))
			{
				continue;
			}
			$found = array_diff(scandir($path . DS . 'migrations'), $exclude);

			foreach ($found as $f)
			{
				$files[$path . DS . 'migrations' . DS . $f] = $f;
			}
		}

		asort($files);

		if (!is_null($file))
		{
			if (in_array($file, $files))
			{
				$this->files[] = array_search($file, $files);
				return true;
			}
			else
			{
				$this->log("Provided file ({$file}) could not be found.", 'error');
				return false;
			}
		}

		if (!is_null($extension))
		{
			$parts = explode('_', $extension);
			foreach ($parts as $part)
			{
				$ext .= ucfirst($part);
			}
		}

		foreach ($files as $path => $file)
		{
			// Make sure they have a php extension and proper filename format
			if (preg_match('/^Migration[0-9]{14}[[:alnum:]]+\.php$/', $file))
			{
				// If an extension was provided...match against it...
				if (empty($ext) || (!empty($ext) && preg_match('/Migration[0-9]{14}'.$ext.'\.php/', $file)))
				{
					$this->files[] = $path;
				}
			}
		}

		return true;
	}
public function find ( $ extension = null , $ file = null ) { // Exclude certain thiings from our search $ exclude = array ( "." , ".." ) ; $ files = [ ] ; $ ext = '' ; foreach ( $ this -> searchPaths as $ path ) { if ( ! is_dir ( $ path . DS . 'migrations' ) ) { continue ; } $ found = array_diff ( scandir ( $ path . DS . 'migrations' ) , $ exclude ) ; foreach ( $ found as $ f ) { $ files [ $ path . DS . 'migrations' . DS . $ f ] = $ f ; } } asort ( $ files ) ; if ( ! is_null ( $ file ) ) { if ( in_array ( $ file , $ files ) ) { $ this -> files [ ] = array_search ( $ file , $ files ) ; return true ; } else { $ this -> log ( "Provided file ({$file}) could not be found." , 'error' ) ; return false ; } } if ( ! is_null ( $ extension ) ) { $ parts = explode ( '_' , $ extension ) ; foreach ( $ parts as $ part ) { $ ext .= ucfirst ( $ part ) ; } } foreach ( $ files as $ path => $ file ) { // Make sure they have a php extension and proper filename format if ( preg_match ( '/^Migration[0-9]{14}[[:alnum:]]+\.php$/' , $ file ) ) { // If an extension was provided...match against it... if ( empty ( $ ext ) || ( ! empty ( $ ext ) && preg_match ( '/Migration[0-9]{14}' . $ ext . '\.php/' , $ file ) ) ) { $ this -> files [ ] = $ path ; } } } return true ; }
Find all migration scripts

@param   string  $extension  Only look for migrations for this extension
@param   string  $file       The specific file to run
@return  array
Find all migration scripts