actions.class.php 1.67 KB
Newer Older
Яков's avatar
first  
Яков committed
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php

require_once dirname(__FILE__).'/../lib/offerGeneratorConfiguration.class.php';
require_once dirname(__FILE__).'/../lib/offerGeneratorHelper.class.php';

/**
 * offer actions.
 *
 * @package    sf
 * @subpackage offer
 * @author     Atma
 * @version    SVN: $Id: actions.class.php 23810 2009-11-12 11:07:44Z Kris.Wallsmith $
 */
class offerActions extends autoOfferActions
{
    public function executeUpdate(sfWebRequest $request)
    {
        parent::executeUpdate($request);
        return sfView::NONE;
    }
    public function executeCreate(sfWebRequest $request)
    {
        parent::executeCreate($request);
        return sfView::NONE;
    }
    protected function processForm(sfWebRequest $request, sfForm $form)
    {
        $form->bind($request->getParameter($form->getName()), $request->getFiles($form->getName()));
        if ($form->isValid())
        {
            try
            {
                $offer = $form->save();
                echo $this->getPartial('cat/struct_form', array('form' => new OfferForm($offer), 'parent_id' => Cat::$parentId, 'link' => '/arm/offer' . ($offer ? '/' . $offer->getId() : '')));
                return sfView::NONE;
            }
            catch (Doctrine_Validator_Exception $e)
            {
                $errorStack = $form->getObject()->getErrorStack();
                return sfView::NONE;
            }
            $this->dispatcher->notify(new sfEvent($this, 'admin.save_object', array('object' => $offer)));
        }
        echo $this->getPartial('cat/struct_form', array('form' => $form, 'parent_id' => Cat::$parentId, 'link' => '/arm/offer' . ($this->offer && $this->offer->getId() ? '/' . $this->offer->getId() : '')));
    }
}