public function populateWithFacebook(m14tFacebook $fb, $force = true) { $sfGuardUser = $this->getInvoker(); foreach ($this->_options['fields'] as $fb_key => $sfg_key) { $func = 'get' . sfInflector::camelize($fb_key); switch ($fb_key) { case 'location': case 'hometown': case 'languages': case 'education': $sfGuardUser->{$sfg_key}($fb->{$func}(), $force); break; case 'birthday': if ($force || "" == $sfGuardUser[$sfg_key]) { $sfGuardUser[$sfg_key] = date('Y-m-d', strtotime($fb->{$func}())); } break; default: if ($force || "" == $sfGuardUser[$sfg_key]) { $sfGuardUser[$sfg_key] = $fb->{$func}(); } break; } } }
public function addFields() { // Information object attribute (db column) to perform s/r on $map = new InformationObjectI18nTableMap(); foreach ($map->getColumns() as $col) { if (!$col->isPrimaryKey() && !$col->isForeignKey()) { $col_name = $col->getPhpName(); $choices[$col_name] = sfInflector::humanize(sfInflector::underscore($col_name)); } } $this->form->setValidator('column', new sfValidatorString()); $this->form->setWidget('column', new sfWidgetFormSelect(array('choices' => $choices), array('style' => 'width: auto'))); // Search-replace values $this->form->setValidator('pattern', new sfValidatorString()); $this->form->setWidget('pattern', new sfWidgetFormInput()); $this->form->setValidator('replacement', new sfValidatorString()); $this->form->setWidget('replacement', new sfWidgetFormInput()); $this->form->setValidator('caseSensitive', new sfValidatorBoolean()); $this->form->setWidget('caseSensitive', new sfWidgetFormInputCheckbox()); $this->form->setValidator('allowRegex', new sfValidatorBoolean()); $this->form->setWidget('allowRegex', new sfWidgetFormInputCheckbox()); if ($this->request->isMethod('post') && !isset($this->request->confirm) && !empty($this->request->pattern) && !empty($this->request->replacement)) { $this->form->setValidator('confirm', new sfValidatorBoolean()); $this->form->setWidget('confirm', new sfWidgetFormInputHidden(array(), array('value' => true))); } }
public function getLinkToAction($actionName, $params, $pk_link = false) { $options = isset($params['params']) && !is_array($params['params']) ? sfToolkit::stringToArray($params['params']) : array(); // default values if ($actionName[0] == '_') { $actionName = substr($actionName, 1); $name = $actionName; //$icon = sfConfig::get('sf_admin_web_dir').'/images/'.$actionName.'_icon.png'; $action = $actionName; if ($actionName == 'delete') { $options['post'] = true; if (!isset($options['confirm'])) { $options['confirm'] = 'Are you sure?'; } } } else { $name = isset($params['name']) ? $params['name'] : $actionName; //$icon = isset($params['icon']) ? sfToolkit::replaceConstants($params['icon']) : sfConfig::get('sf_admin_web_dir').'/images/default_icon.png'; $action = isset($params['action']) ? $params['action'] : 'List' . sfInflector::camelize($actionName); } $url_params = $pk_link ? '?' . $this->getPrimaryKeyUrlParams() : '\''; $phpOptions = var_export($options, true); // little hack $phpOptions = preg_replace("/'confirm' => '(.+?)(?<!\\\\)'/", '\'confirm\' => __(\'$1\')', $phpOptions); return '<li class="sf_admin_action_' . sfInflector::underscore($name) . '">[?php echo link_to(__(\'' . $params['label'] . '\'), \'' . $this->getModuleName() . '/' . $action . $url_params . ($options ? ', ' . $phpOptions : '') . ') ?]</li>' . "\n"; }
/** * magic method to use listen to some event * * @param string $methodName * @param array $args */ public function __call($methodName, $args) { if (0 === strpos($methodName, 'listenTo')) { $name = sfInflector::underscore(substr($methodName, 8)); if (!in_array($name, array_keys(self::getPointConfig()))) { throw new BadMethodCallException(); } if (!(1 === count($args) && $args[0] instanceof sfEvent)) { throw new InvalidArgumentException(); } $event = $args[0]; if (0 === strpos($event->getName(), 'op_action.post_execute')) { if (isset(self::$pointConfig[$name]['check'])) { $check = self::$pointConfig[$name]['check']; if ('redirect' === $check && $event->getSubject() instanceof opFrontWebController && sfView::SUCCESS === $event['result'] || $event['result'] === $check) { $this->pointUp($name); } return; } $this->pointUp($name); } return; } throw new BadMethodCallException(); }
public function retrieveGadgetsByTypesName($typesName) { if (isset($this->gadgets[$typesName])) { return $this->gadgets[$typesName]; } if (sfConfig::get('op_is_enable_gadget_cache', true)) { $dir = sfConfig::get('sf_app_cache_dir') . '/config'; $file = $dir . '/' . sfInflector::underscore($typesName) . "_gadgets.php"; if (is_readable($file)) { $results = unserialize(file_get_contents($file)); $this->gadgets[$typesName] = $results; return $results; } } $types = $this->getTypes($typesName); foreach ($types as $type) { $results[$type] = $this->retrieveByType($type); } if (sfConfig::get('op_is_enable_gadget_cache', true)) { if (!is_dir($dir)) { @mkdir($dir, 0777, true); } file_put_contents($file, serialize($results)); } $this->gadgets[$typesName] = $results; return $results; }
protected function getObjectsForParameters($parameters) { $this->options['model'] = Doctrine::getTable($this->options['model']); if (!isset($this->options['method'])) { $variables = $this->getRealVariables(); switch (count($variables)) { case 0: $this->options['method'] = 'findAll'; break; case 1: $this->options['method'] = 'findOneBy' . sfInflector::camelize($variables[0]); $parameters = $parameters[$variables[0]]; break; default: $this->options['method'] = 'findByDQL'; $wheres = array(); foreach ($variables as $variable) { $variable = $this->options['model']->getFieldName($variable); $wheres[] = $variable . " = '" . $parameters[$variable] . "'"; } $parameters = implode(' AND ', $wheres); } } return parent::getObjectsForParameters($parameters); }
protected function compile() { parent::compile(); // =================================== // = Add for exporting configuration = // =================================== $this->configuration['credentials']['export'] = array(); $this->configuration['export'] = array('fields' => array(), 'title' => $this->getExportTitle(), 'actions' => $this->getExportActions() ? $this->getExportActions() : array('_list' => array('action' => 'index', 'label' => 'Back'))); $config = $this->getConfig(); foreach (array_keys($config['default']) as $field) { $formConfig = array_merge($config['default'][$field], isset($config['form'][$field]) ? $config['form'][$field] : array()); $this->configuration['export']['fields'][$field] = new sfModelGeneratorConfigurationField($field, array_merge(array('label' => sfInflector::humanize(sfInflector::underscore($field))), $config['default'][$field], isset($config['export'][$field]) ? $config['export'][$field] : array())); } foreach ($this->getExportDisplay() as $field) { list($field, $flag) = sfModelGeneratorConfigurationField::splitFieldWithFlag($field); $this->configuration['export']['fields'][$field] = new sfModelGeneratorConfigurationField($field, array_merge(array('type' => 'Text', 'label' => sfInflector::humanize(sfInflector::underscore($field))), isset($config['default'][$field]) ? $config['default'][$field] : array(), isset($config['export'][$field]) ? $config['export'][$field] : array(), array('flag' => $flag))); } // export actions foreach ($this->configuration['export']['actions'] as $action => $parameters) { $this->configuration['export']['actions'][$action] = $this->fixActionParameters($action, $parameters); } $this->configuration['export']['display'] = array(); foreach ($this->getExportDisplay() as $name) { list($name, $flag) = sfModelGeneratorConfigurationField::splitFieldWithFlag($name); if (!isset($this->configuration['export']['fields'][$name])) { throw new InvalidArgumentException(sprintf('The field "%s" does not exist.', $name)); } $field = $this->configuration['export']['fields'][$name]; $field->setFlag($flag); $this->configuration['export']['display'][$name] = $field; } }
/** * Executes this filter. * * @param sfFilterChain $filterChain A sfFilterChain instance */ public function execute($filterChain) { // disable stateful security checking on signin and secure actions if (sfConfig::get('sf_login_module') == $this->context->getModuleName() && sfConfig::get('sf_login_action') == $this->context->getActionName() || sfConfig::get('sf_secure_module') == $this->context->getModuleName() && sfConfig::get('sf_secure_action') == $this->context->getActionName()) { $filterChain->execute(); return; } $sf_user = $this->context->getUser(); // retrieve the current action $action = $this->context->getController()->getActionStack()->getLastEntry()->getActionInstance(); // get the current module and action names $module_name = sfInflector::camelize($action->getModuleName()); $action_name = sfInflector::camelize($action->getActionName()); // get the object for the current route $object = $this->getObjectForRoute($action->getRoute()); // i.e.: canIndexDefault $method = "can{$action_name}{$module_name}"; // if the method exist if (method_exists($sf_user, $method)) { // execute it if (!$sf_user->{$method}($object)) { $this->forwardToSecureAction(); } } else { // get the default policy $default_policy = $this->getParameter('default_policy', 'allow'); // if the default policy is not 'allow' if ($default_policy != 'allow') { $this->forwardToSecureAction(); } } $filterChain->execute(); return; }
/** * @see sfTask */ protected function execute($arguments = array(), $options = array()) { /** * include path to propel generator */ sfToolkit::addIncludePath(array(sfConfig::get('sf_propel_path') . '/generator/lib')); /** * first check the db connectivity for all connections */ $this->logBlock('Checking Db Connectivity', "QUESTION"); if (!$this->createTask('afs:db-connectivity')->run()) { return; } $this->logBlock('Creating specific AppFlower folders', "QUESTION"); $this->createFolders(); $this->logBlock('Setting Symfony project permissions', "QUESTION"); $this->createTask('project:permissions')->run(); $type_method = 'execute' . sfInflector::camelize($options['type']); if (!method_exists($this, $type_method)) { throw new sfCommandException("Type method '{$type_method}' not defined."); } call_user_func(array($this, $type_method), $arguments, $options); $this->logBlock('Creating models from current schema', "QUESTION"); $this->createTask('propel:build-model')->run(); $this->logBlock('Creating forms from current schema', "QUESTION"); $this->createTask('propel:build-forms')->run(); $this->logBlock('Setting AppFlower project permissions', "QUESTION"); $this->createTask('afs:fix-perms')->run(); $this->logBlock('Creating AppFlower validator cache', "QUESTION"); $this->createTask('appflower:validator-cache')->run(array('frontend', 'cache', 'yes')); $this->logBlock('Clearing Symfony cache', "QUESTION"); $this->createTask('cc')->run(); }
public function getObjects($fk = null) { if (!$this->_tableMethod) { $query = Doctrine_Core::getTable($this->_model)->createQuery(); if (is_array($order = $this->_orderBy)) { $query->addOrderBy($order[0] . ' ' . $order[1]); } if ($fk) { $refColumn = str_replace('get_', '', sfInflector::underscore($this->_refMethod)); $query->addWhere("{$refColumn} = ?", $fk); } $objects = $query->execute(); } else { $tableMethod = $this->_tableMethod; $results = Doctrine_Core::getTable($this->_model)->{$tableMethod}($fk); if ($results instanceof Doctrine_Query) { $objects = $results->execute(); } else { if ($results instanceof Doctrine_Collection) { $objects = $results; } else { if ($results instanceof Doctrine_Record) { $objects = new Doctrine_Collection($this->_model); $objects[] = $results; } else { $objects = array(); } } } } return $objects; }
/** * Saving changed page information * * @return afResponse * @author Sergey Startsev */ protected function processSave() { // Getting needed parameters - page, application name, and sure definition $page_name = pathinfo($this->getParameter('page'), PATHINFO_FILENAME); $application = $this->getParameter('app'); $definition = $this->getParameter('definition', array()); $module = $this->getParameter('module', self::PAGES_MODULE); $permissions = new Permissions(); $is_writable = $permissions->isWritable(sfConfig::get('sf_apps_dir') . '/' . $application . '/config/pages/'); if ($is_writable !== true) { return $is_writable; } //idXml is stored inside the portal_state table from appFlowerPlugin $idXml = "pages/{$page_name}"; $page = afsPageModelHelper::retrieve($page_name, $application); $is_new = $page->isNew(); $page->setTitle(sfInflector::humanize(sfInflector::underscore($page_name))); $page->setDefinition($definition); $saveResponse = $page->save(); $response = afResponseHelper::create(); if ($saveResponse->getParameter(afResponseSuccessDecorator::IDENTIFICATOR)) { $console = afStudioConsole::getInstance()->execute(array("sf appflower:portal-state-cc {$idXml}", "sf appflower:validator-cache frontend cache yes", 'sf afs:fix-perms')); return $response->success(true)->content(!$is_new ? sprintf('Page <b>%s</b> has been saved', $page_name) : sprintf('Page <b>%s</b> has been created', $page_name))->console($console); } $response->success(false); if ($saveResponse->hasParameter(afResponseMessageDecorator::IDENTIFICATOR)) { $response->content($saveResponse->getParameter(afResponseMessageDecorator::IDENTIFICATOR)); } return $response; }
public function __construct($feed_array = array(), $extensions = array()) { $version = '1.0'; parent::__construct(); /// we call initialize() later so we don't need to pass feed_array in yet $encoding = 'UTF-8'; // sensible default $dom = $this->dom = new DOMDocument($version, $encoding); $this->setEncoding($encoding); // needed to avoid trying to set encoding to '' $this->context = sfContext::getInstance(); $this->plugin_path = realpath(dirname(__FILE__) . '/../'); $prefix = 'sfDomFeedExtension'; $this->extensions = array(); foreach ($extensions as $extension) { $class_name = $prefix . sfInflector::camelize($extension); $extension = new $class_name(); if (!$extension instanceof sfDomFeedExtension) { throw new sfException("{$class_name} is not a sfDomFeedExtension"); } // unfortunately ^ class_exists() is useless here; it will error instead of exception. $this->extensions[] = $extension; } if ($feed_array) { $this->initialize($feed_array); } if (!$dom->load($this->genTemplatePath(), LIBXML_NOERROR)) { throw new sfDomFeedException("DOMDocument::load failed"); } }
protected function executeGenerate($arguments = array(), $options = array()) { // generate module $tmpDir = sfConfig::get('sf_cache_dir') . DIRECTORY_SEPARATOR . 'tmp' . DIRECTORY_SEPARATOR . md5(uniqid(rand(), true)); $generatorManager = new sfGeneratorManager($this->configuration, $tmpDir); $generatorManager->generate('sfDoctrineGenerator', array('model_class' => $arguments['model'], 'moduleName' => $arguments['module'], 'theme' => $options['theme'], 'non_verbose_templates' => $options['non-verbose-templates'], 'with_show' => $options['with-show'], 'singular' => $options['singular'] ? $options['singular'] : sfInflector::underscore($arguments['model']), 'plural' => $options['plural'] ? $options['plural'] : sfInflector::underscore($arguments['model'] . 's'), 'route_prefix' => $options['route-prefix'], 'with_doctrine_route' => $options['with-doctrine-route'], 'actions_base_class' => $options['actions-base-class'])); $moduleDir = sfConfig::get('sf_app_module_dir') . '/' . $arguments['module']; // copy our generated module $this->getFilesystem()->mirror($tmpDir . DIRECTORY_SEPARATOR . 'auto' . ucfirst($arguments['module']), $moduleDir, sfFinder::type('any')); if (!$options['with-show']) { $this->getFilesystem()->remove($moduleDir . '/templates/showSuccess.php'); } // change module name $finder = sfFinder::type('file')->name('*.php'); $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '', '', array('auto' . ucfirst($arguments['module']) => $arguments['module'])); // customize php and yml files $finder = sfFinder::type('file')->name('*.php', '*.yml'); $this->getFilesystem()->replaceTokens($finder->in($moduleDir), '##', '##', $this->constants); // create basic test $this->getFilesystem()->copy(sfConfig::get('sf_symfony_lib_dir') . DIRECTORY_SEPARATOR . 'task' . DIRECTORY_SEPARATOR . 'generator' . DIRECTORY_SEPARATOR . 'skeleton' . DIRECTORY_SEPARATOR . 'module' . DIRECTORY_SEPARATOR . 'test' . DIRECTORY_SEPARATOR . 'actionsTest.php', sfConfig::get('sf_test_dir') . DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . $arguments['application'] . DIRECTORY_SEPARATOR . $arguments['module'] . 'ActionsTest.php'); // customize test file $this->getFilesystem()->replaceTokens(sfConfig::get('sf_test_dir') . DIRECTORY_SEPARATOR . 'functional' . DIRECTORY_SEPARATOR . $arguments['application'] . DIRECTORY_SEPARATOR . $arguments['module'] . 'ActionsTest.php', '##', '##', $this->constants); // delete temp files $this->getFilesystem()->remove(sfFinder::type('any')->in($tmpDir)); }
public static function retrieveOrCreateByObject(BaseObject $object) { if ($object->isNew() === true || $object->isModified() === true || $object->isDeleted() === true) { throw new Exception('You can only approve an object which has already been saved'); } $columnName = sfConfig::get('propel_behavior_sfPropelApprovableBehavior_' . get_class($object) . '_column', 'is_approved'); $approvedValue = sfConfig::get('propel_behavior_sfPropelApprovableBehavior_' . get_class($object) . '_approved_value', true); $disabledApplications = sfConfig::get('propel_behavior_sfPropelApprovableBehavior_' . get_class($object) . '_disabled_applications'); // Test if we should crated an approval - is the column value different to out required value? // If our object is already approved then we can delete other $columnGetter = 'get' . sfInflector::camelize($columnName); if ($approvedValue != $object->{$columnGetter}()) { $c = new Criteria(); $c->add(sfApprovalPeer::APPROVABLE_ID, $object->getPrimaryKey()); $c->add(sfApprovalPeer::APPROVABLE_MODEL, get_class($object)); $approval = sfApprovalPeer::doSelectOne($c); if (!$approval) { $approval = new sfApproval(); $approval->setApprovableModel(get_class($object)); $approval->setApprovableId($object->getPrimaryKey()); $approval->setUuid(sfPropelApprovableToolkit::generateUuid()); $approval->save(); } return $approval; } else { sfApprovalPeer::deleteByObject($object); return null; } return $approval; }
public function __get($name) { if (in_array($name, array('base_amount', 'discount_amount', 'net_amount', 'tax_amount', 'gross_amount'))) { $m = sfInflector::camelize("get_{$name}"); return $this->{$m}(); } return parent::__get($name); }
public function initialize($context, $moduleName, $actionName, $viewName) { $this->nameSuffix = sfSmartphoneViewToolKit::getViewNameSuffixFromUA($this, $context, $moduleName, $actionName, $viewName, false); if ($this->nameSuffix) { $this->enableNameSuffix = sfSmartphoneViewToolKit::getViewNameSuffixFromUA($this, $context, $moduleName, $actionName, $viewName); } parent::initialize($context, $moduleName, $actionName, $viewName . sfInflector::camelize($this->enableNameSuffix)); }
public function getAttachmentsByType($type) { if (in_array($type, $this->_options['types'])) { return $this->getAttachmentsByTypeQuery($type)->execute(); } $table = strtolower($type) == 'other' ? 'Attachment' : sfInflector::classify($type . '_attachment'); return new Doctrine_Collection($table); }
public function setup($options, $parameters = array()) { $ret = parent::setup($options, $parameters); $this->humanizedModuleName = sfInflector::humanize($this->moduleName); return $ret; }
public static function create($class, $title = null, $multisheet = false) { $managerClass = sprintf('sfExportManager%s', sfInflector::camelize($class)); if (class_exists($managerClass)) { return new $managerClass($class, $title, $multisheet); } return new self($class, $title, $multisheet); }
/** * This method exists only for BC */ public static function arrayKeyCamelize(array $array) { foreach ($array as $key => $value) { unset($array[$key]); $array[sfInflector::classify($key)] = $value; } return $array; }
public function getGenereatedLabel($name) { $label = $this->getLabel(); if (null === $label) { $label = sfInflector::humanize($name); } return $label; }
public function executeFeed() { /** @var sfWebRequest **/ $request = $this->getContext()->getRequest(); $IdType = $this->getRequestParameter('IdType', null); $id = $this->getRequestParameter('id', null); //Build the title $title = "Metadata Registry Change History"; $filter = false; switch ($IdType) { //ElementSet :: (Schema)Element :: (Schema)ElementProperty //Schema :: SchemaProperty :: SchemaPropertyElement case "schema_property_element_id": /** @var SchemaPropertyElement **/ $element = DbFinder::from('SchemaPropertyElement')->findPk($id); if ($element) { /** @var SchemaProperty **/ $property = $element->getSchemaPropertyRelatedBySchemaPropertyId(); $title .= " for Property: '" . $element->getProfileProperty()->getLabel(); if ($property) { $title .= "' of Element: '" . $property->getLabel() . "' in Element Set: '" . $property->getSchema()->getName() . "'"; } } $filter = true; break; case "schema_property_id": /** @var SchemaProperty **/ $property = DbFinder::from('SchemaProperty')->findPk($id); if ($property) { $title .= " for Element: '" . $property->getLabel() . "' in Element Set: '" . $property->getSchema()->getName() . "'"; } $filter = true; break; case "schema_id": /** @var Schema **/ $schema = DbFinder::from('Schema')->findPk($id); if ($schema) { $title .= " for Element Set: '" . $schema->getName() . "'"; } $filter = true; break; default: //the whole shebang $title .= " for all Element Sets"; break; } $column = sfInflector::camelize($IdType); //default limit to 100 if not set in config $limit = $request->getParameter('nb', sfConfig::get('app_frontend_feed_count', 100)); $finder = DbFinder::from('SchemaPropertyElementHistory')->orderBy('SchemaPropertyElementHistory.CreatedAt', 'desc')->join('SchemaPropertyElementHistory.SchemaPropertyElementId', 'SchemaPropertyElement.Id', 'left join')->join('SchemaProperty', 'left join')->join('Schema', 'left join')->join('Status', 'left join')->join('User', 'left join')->join('ProfileProperty', 'left join')->with('Schema', 'ProfileProperty', 'User', 'Status', 'SchemaProperty'); if ($filter) { $finder = $finder->where('SchemaPropertyElementHistory.' . $column, $id); } $finder = $finder->find($limit); $this->setTemplate('feed'); $this->feed = sfFeedPeer::createFromObjects($finder, array('format' => $request->getParameter('format', 'atom1'), 'link' => $request->getUriPrefix() . $request->getPathInfo(), 'feedUrl' => $request->getUriPrefix() . $request->getPathInfo(), 'title' => htmlentities($title), 'methods' => array('authorEmail' => '', 'link' => 'getFeedUniqueId'))); return; }
public function filterGet(Doctrine_Record $record, $name) { $method = 'get' . sfInflector::camelize($name); $event = sfProjectConfiguration::getActive()->getEventDispatcher()->notifyUntil(new sfEvent($record, 'sympal.' . $this->_eventName . '.method_not_found', array('method' => $method))); if ($event->isProcessed()) { return $event->getReturnValue(); } throw new Doctrine_Record_UnknownPropertyException(sprintf('Unknown record property / related component "%s" on "%s"', $name, get_class($record))); }
public function fromArray($params) { foreach ($this as $prop => $value) { $optName = sfInflector::underscore(str_replace('_', '', $prop)); if (isset($params[$optName])) { $this->{$prop} = $params[$optName]; } } }
public function getLinkToAction($actionName, $params, $pk_link = false) { $action = isset($params['action']) ? $params['action'] : 'List' . sfInflector::camelize($actionName); $url_params = $pk_link ? '?' . $this->getPrimaryKeyUrlParams() : '\''; if (isset($params['extend_url'])) { $url_params .= '.(has_slot(\'sf_admin.extend_url\') ? \'' . $params['extend_url'] . '\'.get_slot(\'sf_admin.extend_url\') : \'\')'; } return '[?php echo link_to(__(\'' . $params['label'] . '\', array(), \'' . $this->getI18nCatalogue() . '\'), \'' . (isset($params['module']) ? $params['module'] : $this->getModuleName()) . '/' . $action . $url_params . ', ' . $this->asPhp($params['params']) . ') ?]'; }
/** * Can be used inside a magic __call method to allow for a class to be extended * * This method will throw a class_name.method_not_found event, * where class_name is the "tableized" class name. * * @example * public function __call($method, $arguments) * { * return sfSympalExtendClass::extendEvent($this, $method, $arguments); * } * * @param mixed $subject Instance of the class being extended * @param string $method The current method being called * @param array $arguments The arguments being passed to the above methid */ public static function extendEvent($subject, $method, $arguments) { $name = sfInflector::tableize(get_class($subject)); $event = ProjectConfiguration::getActive()->getEventDispatcher()->notifyUntil(new sfEvent($subject, $name . '.method_not_found', array('method' => $method, 'arguments' => $arguments))); if (!$event->isProcessed()) { throw new sfException(sprintf('Call to undefined method %s::%s.', get_class($subject), $method)); } return $event->getReturnValue(); }
/** * Renders the presentation and send the email to the client. * * @return mixed Raw data of the mail */ public function render() { $retval = null; // execute pre-render check $this->preRenderCheck(); // get sfMail object from action $mail = $this->attributeHolder->get('mail'); if (!$mail) { throw new sfActionException('You must define a sfMail object named $mail ($this->mail) in your action to be able to use a sfMailView.'); } // render main template $template = $this->getDirectory() . '/' . $this->getTemplate(); $retval = $this->renderFile($template); // render main and alternate templates $all_template_dir = dirname($template); $all_template_regex = preg_replace('/\\.php$/', '\\..+\\.php', basename($template)); $all_templates = sfFinder::type('file')->name('/^' . $all_template_regex . '$/')->in($all_template_dir); $all_retvals = array(); foreach ($all_templates as $templateFile) { if (preg_match('/\\.([^.]+?)\\.php$/', $templateFile, $matches)) { $all_retvals[$matches[1]] = $this->renderFile($templateFile); } } // send email if (sfConfig::get('sf_logging_enabled')) { $this->dispatcher->notify(new sfEvent($this, 'application.log', array('Send email to client'))); } // configuration prefix $config_prefix = 'sf_mailer_' . strtolower($this->moduleName) . '_'; $vars = array('mailer', 'priority', 'content_type', 'charset', 'encoding', 'wordwrap', 'hostname', 'port', 'domain', 'username', 'password'); $defaultMail = new sfMail(); foreach ($vars as $var) { $setter = 'set' . sfInflector::camelize($var); $getter = 'get' . sfInflector::camelize($var); $value = $mail->{$getter}() !== $defaultMail->{$getter}() ? $mail->{$getter}() : sfConfig::get($config_prefix . strtolower($var)); $mail->{$setter}($value); } $mail->setBody($retval); // alternate bodies $i = 0; foreach ($all_retvals as $type => $retval) { if ($type == 'altbody' && !$mail->getAltBody()) { $mail->setAltBody($retval); } else { ++$i; $mail->addStringAttachment($retval, 'file' . $i, 'base64', 'text/' . $type); } } // preparing email to be sent $mail->prepare(); // send e-mail if (sfConfig::get($config_prefix . 'deliver')) { $mail->send(); } return $mail->getRawHeader() . $mail->getRawBody(); }
public function setup() { $this->askForApplication(); $this->askForModel(); $this->task->bootstrapSymfony($this->options['application'], $this->options['env']); $this->askForOption('module', null, sfInflector::underscore($this->options['model'])); }
public function configure() { foreach (opSkinClassicConfig::getAllowdColors() as $color) { $this->setWidget($color, new sfWidgetFormInputText()); $this->widgetSchema->setLabel($color, sfInflector::humanize($color)); $this->setValidator($color, new sfValidatorCallback(array('callback' => array('opSkinClassicColorForm', 'validateHex')))); $this->setDefault($color, opSkinClassicConfig::get($color)); } $this->widgetSchema->setNameFormat('color[%s]'); }
/** * Runs all test methods * * @return null */ public function run() { foreach ($this->getTestMethods() as $method) { $test = $method->getName(); $this->info(sfInflector::humanize(sfInflector::underscore(substr($test, 4)))); $this->setUp(); $this->{$test}(); $this->tearDown(); } }