コード例 #1
0
ファイル: Assets.php プロジェクト: snscripts/html-helper
 /**
  * base function to return assets
  *
  * @param   mixed   asset path data received from the image method
  * @return  string  url to pass to img or css
  */
 protected function getAsset($assetData)
 {
     try {
         $Comet = \CometPHP\Comet::getInstance();
     } catch (\CometPHP\Exceptions\CometNotBooted $e) {
         return null;
     }
     if (!is_array($assetData)) {
         $assetData = [$assetData];
     }
     $asset = $Comet['template']->getFunction('asset')->call($this->template, $assetData);
     return $asset;
 }
コード例 #2
0
ファイル: Router.php プロジェクト: snscripts/html-helper
 /**
  * base function to return the url for the link method
  *
  * @param   mixed   url data received from the link method
  * @return  string  url to pass to href
  */
 public function getUrl($url)
 {
     if (is_array($url) && !empty($url['route'])) {
         try {
             $Comet = \CometPHP\Comet::getInstance();
         } catch (\CometPHP\Exceptions\CometNotBooted $e) {
             return null;
         }
         $routeName = $url['route'];
         unset($url['route']);
         $generatedUrl = $Comet['routeGenerator']->generate($routeName, $url);
         return $generatedUrl;
     }
     return $url;
 }
コード例 #3
0
ファイル: Data.php プロジェクト: snscripts/html-helper
 /**
  * get the post data to prefill the inputs
  *
  * @param   string      dot notation format of the input name we're looking for
  * @return  mixed|null  Return value from post data or null if not found
  */
 public function getValue($name)
 {
     if (!is_string($name)) {
         return null;
     }
     try {
         $Comet = \CometPHP\Comet::getInstance();
     } catch (\CometPHP\Exceptions\CometNotBooted $e) {
         return null;
     }
     $bits = explode('.', $name);
     $postData = $Comet['request']->request->all();
     foreach ($bits as $key) {
         if (is_array($postData) && isset($postData[$key])) {
             $postData = $postData[$key];
         } else {
             return null;
         }
     }
     return $postData;
 }