Example #1
0
 /**
  * This is just for compatibility, this method will be removed with the next major release
  * @depricated
  * @static
  * @param $config
  * @return self
  */
 public static function getByLegacyConfig($config)
 {
     $pipe = new self();
     if (isset($config["format"])) {
         $pipe->setFormat($config["format"]);
     }
     if (isset($config["quality"])) {
         $pipe->setQuality($config["quality"]);
     }
     if (isset($config["cover"])) {
         $pipe->addItem("cover", ["width" => $config["width"], "height" => $config["height"], "positioning" => "center"]);
     } elseif (isset($config["contain"])) {
         $pipe->addItem("contain", ["width" => $config["width"], "height" => $config["height"]]);
     } elseif (isset($config["frame"])) {
         $pipe->addItem("frame", ["width" => $config["width"], "height" => $config["height"]]);
     } elseif (isset($config["aspectratio"]) && $config["aspectratio"]) {
         if (isset($config["height"]) && isset($config["width"]) && $config["height"] > 0 && $config["width"] > 0) {
             $pipe->addItem("contain", ["width" => $config["width"], "height" => $config["height"]]);
         } elseif (isset($config["height"]) && $config["height"] > 0) {
             $pipe->addItem("scaleByHeight", ["height" => $config["height"]]);
         } else {
             $pipe->addItem("scaleByWidth", ["width" => $config["width"]]);
         }
     } else {
         if (!isset($config["width"]) && isset($config["height"])) {
             $pipe->addItem("scaleByHeight", ["height" => $config["height"]]);
         } elseif (isset($config["width"]) && !isset($config["height"])) {
             $pipe->addItem("scaleByWidth", ["width" => $config["width"]]);
         } elseif (isset($config["width"]) && isset($config["height"])) {
             $pipe->addItem("resize", ["width" => $config["width"], "height" => $config["height"]]);
         }
     }
     if (isset($config["highResolution"])) {
         $pipe->setHighResolution($config["highResolution"]);
     }
     $hash = md5(Serialize::serialize($pipe));
     $pipe->setName("auto_" . $hash);
     return $pipe;
 }
Example #2
0
 /**
  * Create datetime rule
  * @param \BX\DB\Filter\SqlBuilder $filter
  * @return \BX\DB\Filter\Rule\DateTime
  */
 public static function full(SqlBuilder $filter)
 {
     $date = new self($filter);
     return $date->setFormat('full');
 }