Nette\Utils\Finder::extensionMethod PHP Method

extensionMethod() public static method

public static extensionMethod ( $name, $callback )
    public static function extensionMethod($name, $callback)
    {
        Nette\Utils\ObjectMixin::setExtensionMethod(__CLASS__, $name, $callback);
    }

Usage Example

Ejemplo n.º 1
0
	});
});



/**
 * Restricts the search by images dimensions.
 * @param  string
 * @param  string
 * @return Nette\Utils\Finder  provides a fluent interface
 */
Finder::extensionMethod('dimensions', function($finder, $width, $height){
	if (!preg_match('#^([=<>!]+)\s*(\d+)$#i', $width, $mW) || !preg_match('#^([=<>!]+)\s*(\d+)$#i', $height, $mH)) {
		throw new InvalidArgumentException('Invalid dimensions predicate format.');
	}
	return $finder->filter(function($file) use ($mW, $mH) {
		return $file->getSize() >= 12 && ($size = getimagesize($file->getPathname()))
			&& (!$mW || Finder::compare($size[0], $mW[1], $mW[2]))
			&& (!$mH || Finder::compare($size[1], $mH[1], $mH[2]));
	});
});





?>
<!DOCTYPE html>
<html lang="en">
<head>
	<meta http-equiv="content-type" content="text/html; charset=utf-8">
All Usage Examples Of Nette\Utils\Finder::extensionMethod