当前位置: 首页>>代码示例>>PHP>>正文


PHP Doctrine_Event::getInvoker方法代码示例

本文整理汇总了PHP中Doctrine_Event::getInvoker方法的典型用法代码示例。如果您正苦于以下问题:PHP Doctrine_Event::getInvoker方法的具体用法?PHP Doctrine_Event::getInvoker怎么用?PHP Doctrine_Event::getInvoker使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在Doctrine_Event的用法示例。


在下文中一共展示了Doctrine_Event::getInvoker方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: _createOperationLog

 /**
  * Creates a new logging instance.
  *
  * @param Doctrine_Event $event  Event.
  * @param int            $opType I/U/D for Insert/Update/Delete.
  *
  * @return void
  */
 private function _createOperationLog(Doctrine_Event $event, $opType = 'I')
 {
     $data = $event->getInvoker();
     $tableName = $this->getTableNameFromEvent($event);
     $idColumn = $this->getIdColumnFromEvent($event);
     $log = array();
     $log['object_type'] = $tableName;
     $log['object_id'] = $data[$idColumn];
     $log['op'] = $opType;
     if ($opType == 'U') {
         $oldValues = $data->getLastModified(true);
         $diff = array();
         foreach ($oldValues as $column => $oldValue) {
             if (empty($oldValue) && isset($data[$column]) && !empty($data[$column])) {
                 $diff[$column] = 'I: ' . $data[$column];
             } elseif (!empty($oldValue) && isset($data[$column]) && !empty($data[$column])) {
                 $diff[$column] = 'U: ' . $data[$column];
             } elseif (!empty($oldValue) && empty($data[$column])) {
                 $diff[$column] = 'D: ' . $oldValue;
             }
         }
         $log['diff'] = serialize($diff);
     } else {
         // Convert object to array (otherwise we serialize the record object)
         $log['diff'] = serialize($data->toArray());
     }
     DBUtil::insertObject($log, 'objectdata_log');
 }
开发者ID:Silwereth,项目名称:core,代码行数:36,代码来源:Logging.php

示例2: preUpdate

 /**
  * Pre update event hook for inserting new version record
  * This will only insert a version record if the auditLog is enabled
  *
  * @param  Doctrine_Event $event
  * @return void
  */
 public function preUpdate(Doctrine_Event $event)
 {
     $disabled = $event->getInvoker()->hasMappedValue('disable_versioning') ? $event->getInvoker()->get('disable_versioning') : false;
     if (!$disabled) {
         parent::preUpdate($event);
     }
 }
开发者ID:theolymp,项目名称:diem,代码行数:14,代码来源:Listener.php

示例3: preSave

 /**
  * Throws an exception if the record is modified while it is 
  * locked. 
  * 
  * @param Doctrine_Event $event 
  * @return void
  */
 public function preSave(Doctrine_Event $event)
 {
     $modelName = Doctrine_Inflector::tableize(get_class($event->getInvoker()));
     $modifiedFields = $event->getInvoker()->getModified();
     $locked = $event->getInvoker()->isLocked;
     $lockModified = array_key_exists('isLocked', $modifiedFields);
     $numModified = count($modifiedFields);
     /**
      * Record fields haven't been modified, nothing to do here. 
      */
     if (!$event->getInvoker()->isModified()) {
         return;
     }
     /**
      * The record is not locked, and the lock isn't being changed, nothing to do here. 
      */
     if (!$locked && !$lockModified) {
         return;
     }
     /**
      * Only the lock is being modified so there's nothing to
      * do here. 
      */
     if ($lockModified && $numModified == 1) {
         return;
     }
     /**
      * The record is locked, throw an exception. 
      */
     if ($locked) {
         throw new Behavior_Lockable_Exception('The record must be unlocked before it can be modified.');
     }
 }
开发者ID:boydjd,项目名称:doctrine-addons,代码行数:40,代码来源:Listener.php

示例4: preDelete

 public function preDelete(Doctrine_Event $event)
 {
     $table = $event->getInvoker()->getTable();
     $targets = $this->detectCascadingTargets($table);
     foreach ($targets as $target) {
         $relations = $event->getInvoker()->{$target}['alias'];
         if (!$relations instanceof Doctrine_Collection) {
             if (!count($relations)) {
                 continue;
             }
             $relations = array($relations);
         }
         foreach ($relations as $record) {
             switch (strtolower($target['delete'])) {
                 case 'cascade':
                     if ($record instanceof Doctrine_Record) {
                         $record->delete();
                     }
                     break;
                 case 'set null':
                     $record->{$target}['localFrom'] = null;
                     $record->save();
                     break;
                 default:
                     // do nothing
             }
         }
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:29,代码来源:opApplicationLevelCascadingListener.class.php

示例5: preUpdate

 /**
  * preUpdate
  *
  * @param object $Doctrine_Event
  * @return void
  */
 public function preUpdate(Doctrine_Event $event)
 {
     $updatedName = $this->_options['updated']['name'];
     $modified = $event->getInvoker()->getModified();
     if (!isset($modified[$updatedName])) {
         $event->getInvoker()->{$updatedName} = self::getCurrentUserId();
     }
 }
开发者ID:jackbravo,项目名称:amaranto,代码行数:14,代码来源:Userstampable.php

示例6: postConnect

 /**
  * Post-connect listener. Will set charset and run init queries if configured.
  *
  * @param      Doctrine_Event The Doctrine event object.
  *
  * @author     David Zülke <david.zuelke@bitextender.com>
  * @since      1.0.4
  */
 public function postConnect(Doctrine_Event $event)
 {
     if ($this->database->hasParameter('charset')) {
         $event->getInvoker()->setCharset($this->database->getParameter('charset'));
     }
     foreach ((array) $this->database->getParameter('init_queries') as $query) {
         $event->getInvoker()->exec($query);
     }
 }
开发者ID:philippjenni,项目名称:icinga-web,代码行数:17,代码来源:AgaviDoctrineDatabaseEventListener.class.php

示例7: preSave

 /**
  * Pre-save logic.
  *
  * Use preSave instead of preUpdate since the latter depends on the record's
  * state, which isn't necessarily dirty.
  *
  * @see Doctrine_Record_Listener
  */
 public function preSave(Doctrine_Event $event)
 {
     // this listener may have been added several times with a different $form instance
     // but as listeners have a model rather than a record scope we need to filter if
     // this current listener actually matches!
     if ($this->form->getObject()->id == $event->getInvoker()->id) {
         $this->doPreSave($event->getInvoker(), $this->form);
     }
 }
开发者ID:rschumacher,项目名称:sfDoctrineDynamicFormRelationsPlugin,代码行数:17,代码来源:sfDoctrineDynamicFormRelationsListener.class.php

示例8: preDelete

 public function preDelete(Doctrine_Event $event)
 {
     $id = $event->getInvoker()->getId();
     $foreignTableName = $event->getInvoker()->getTable()->getTableName();
     $records = Doctrine::getTable('ActivityData')->findByForeignTableAndForeignId($foreignTableName, $id);
     if ($records instanceof Doctrine_Collection) {
         $records->delete();
     }
 }
开发者ID:te-koyama,项目名称:openpne,代码行数:9,代码来源:opActivityCascadingListener.class.php

示例9: postSave

 /**
  * Executes save routine
  */
 public function postSave(Doctrine_Event $event)
 {
     if ($event->getInvoker()->doIndex()) {
         try {
             $this->saveIndex($event->getInvoker());
         } catch (sfException $e) {
             // no context define, cannot do anything,
         }
     }
 }
开发者ID:bshaffer,项目名称:Symplist,代码行数:13,代码来源:myLuceneDoctrineListener.php

示例10: postInsert

 public function postInsert(Doctrine_Event $event)
 {
     if ('first' === $this->_options['new']) {
         $position = $event->getInvoker()->getTable()->createQuery('r')->select('MIN(r.position)')->fetchValue() - 1;
     } else {
         $position = $event->getInvoker()->get('id');
     }
     $event->getInvoker()->set('position', $position);
     $event->getInvoker()->save();
 }
开发者ID:jdart,项目名称:diem,代码行数:10,代码来源:DmSortable.php

示例11: postValidate

 /**
  * Checks if the file exists in file system. If it does not exists,
  * the validator screams.
  *
  * @param Doctrine_Event $event
  * @return void
  */
 public function postValidate(Doctrine_Event $event)
 {
     if ($this->_options['checkExistence']) {
         $file = $event->getInvoker()->getFile();
         if (!$file->fileExists()) {
             $error_stack = $event->getInvoker()->getErrorStack();
             $error_stack->add($this->_options['name'], 'The file does not exist.');
         }
     }
 }
开发者ID:joshiausdemwald,项目名称:sfFilebasePlugin,代码行数:17,代码来源:File.php

示例12: preUpdate

 public function preUpdate(Doctrine_Event $event)
 {
     $modified = $event->getInvoker()->getModified();
     $modified_old = $event->getInvoker()->getModified(true);
     if (key_exists('created_by', $modified)) {
         $event->getInvoker()->created_by = $modified_old['created_by'];
     }
     if ($user = sfContext::getInstance()->getUser()) {
         $event->getInvoker()->updated_by = $user->getGuardUser() ? $user->getGuardUser()->getId() : null;
     } else {
         if (key_exists('updated_by', $modified)) {
             $event->getInvoker()->updated_by = $modified_old['updated_by'];
         }
     }
 }
开发者ID:nova76,项目名称:nova-plugins,代码行数:15,代码来源:sfCreatorSaveListener.class.php

示例13: preSave

 /**
  * preSave.
  *
  * @param Doctrine_Event $event
  */
 public function preSave($event)
 {
     $record = $event->getInvoker();
     if ($record->isNew()) {
         $file = $record->getFilename();
         if ($file != basename($file) && is_file($file)) {
             $fs = new lyMediaFileSystem();
             $dest_path = $record->getFolderPath();
             $dest_file = $fs->generateUniqueFileName($dest_path, basename($file));
             $fs->import($file, $dest_path . $dest_file);
             $record->setType(mime_content_type($file));
             $record->setFilename($dest_file);
         }
         if ($record->supportsThumbnails()) {
             lyMediaTools::generateThumbnails($record->getFolderPath(), $record->getFilename());
         }
     } else {
         $modified = $record->getModified(true);
         if (isset($modified['folder_id']) || isset($modified['filename'])) {
             //Selected new folder or edited filename: move/rename asset
             $dest_folder = Doctrine::getTable('lyMediaFolder')->find($record->getFolderId());
             $src_folder = $dest_folder;
             if (isset($modified['folder_id'])) {
                 $src_folder = Doctrine::getTable('lyMediaFolder')->find($modified['folder_id']);
             }
             $src = $src_folder->getRelativePath() . (isset($modified['filename']) ? $modified['filename'] : $record->getFileName());
             $dest = $dest_folder->getRelativePath() . $record->getFileName();
             $fs = new lyMediaFileSystem();
             $fs->rename($src, $dest, $record->supportsThumbnails());
         }
     }
 }
开发者ID:pycmam,项目名称:lyMediaManagerPlugin,代码行数:37,代码来源:PluginlyMediaAsset.class.php

示例14: preUpdate

 public function preUpdate(Doctrine_Event $event)
 {
     $record = $event->getInvoker();
     if ($record->isModified()) {
         $this->denormalize($record);
     }
 }
开发者ID:heristop,项目名称:SerializableDoctrineBehavior,代码行数:7,代码来源:Serializable.php

示例15: preSave

 public function preSave(Doctrine_Event $event)
 {
     $invoker = $event->getInvoker();
     $modified = $invoker->getModified();
     if ($invoker->isNew()) {
         // Check if the model is spam
         $akismet = $this->getAkismet($invoker);
         if ($akismet && (is_bool($akismet) || $akismet->isCommentSpam())) {
             $invoker->is_not_spam = false;
             $invoker->is_active = false;
         } else {
             $invoker->is_not_spam = true;
         }
     } else {
         if (isset($modified['is_not_spam'])) {
             $akismet = $this->getAkismet($invoker);
             if ($akismet) {
                 if (!$invoker->is_not_spam) {
                     $akismet->submitSpam();
                 } else {
                     $akismet->submitHam();
                 }
             }
         }
     }
 }
开发者ID:jeremyfa,项目名称:dmAkismetPlugin,代码行数:26,代码来源:DmAkismet.php


注:本文中的Doctrine_Event::getInvoker方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。