コード例 #1
0
ファイル: Snippet.php プロジェクト: Goucher/shopware
 /**
  * Create snippet action
  */
 public function createSnippetAction()
 {
     $snippets = $this->Request()->getPost();
     $result = array();
     if (array_key_exists('namespace', $snippets)) {
         $snippets = array($snippets);
     }
     foreach ($snippets as $params) {
         $snippet = new Snippet();
         $snippet->fromArray($params);
         $snippet->setDirty(true);
         try {
             Shopware()->Models()->persist($snippet);
             Shopware()->Models()->flush();
         } catch (Exception $e) {
             $this->View()->assign(array('success' => false, 'message' => $e->getMessage()));
             return;
         }
         $result[$snippet->getId()] = Shopware()->Models()->toArray($snippet);
     }
     $this->View()->assign(array('success' => true, 'data' => $result));
 }
コード例 #2
0
ファイル: Snippet.php プロジェクト: ClaudioThomas/shopware-4
 /**
  * Create snippet action
  */
 public function createSnippetAction()
 {
     $params = $this->Request()->getPost();
     $snippet = new Snippet();
     $snippet->fromArray($params);
     $snippet->setDirty(true);
     try {
         Shopware()->Models()->persist($snippet);
         Shopware()->Models()->flush();
     } catch (Exception $e) {
         $this->View()->assign(array('success' => false, 'message' => $e->getMessage()));
         return;
     }
     $data = Shopware()->Models()->toArray($snippet);
     $this->View()->assign(array('success' => true, 'data' => $data));
 }