From 131702dd2c3890d50269742d2443ed7d9f1240e4 Mon Sep 17 00:00:00 2001
From: gloas <gloas@afi-sa.fr>
Date: Mon, 9 Jan 2017 17:10:57 +0100
Subject: [PATCH] clean call to hold ressourceDefinition file

---
 library/ZendAfi/Controller/Action.php         |   5 -
 .../Action/RessourceDefinitions.php           | 245 ------------------
 .../ZendAfi/Controller/Plugin/Abstract.php    |   6 -
 3 files changed, 256 deletions(-)
 delete mode 100644 library/ZendAfi/Controller/Action/RessourceDefinitions.php

diff --git a/library/ZendAfi/Controller/Action.php b/library/ZendAfi/Controller/Action.php
index 44f4d9ce4d1..b75920f4f49 100644
--- a/library/ZendAfi/Controller/Action.php
+++ b/library/ZendAfi/Controller/Action.php
@@ -103,11 +103,6 @@ class ZendAfi_Controller_Action extends Zend_Controller_Action {
   }
 
 
-  public function getRessourceDefinitions() {
-    return [];
-  }
-
-
   public function setResourceDefinition($definitions) {
     $this->_definitions = $definitions;
   }
diff --git a/library/ZendAfi/Controller/Action/RessourceDefinitions.php b/library/ZendAfi/Controller/Action/RessourceDefinitions.php
deleted file mode 100644
index ec590aafafa..00000000000
--- a/library/ZendAfi/Controller/Action/RessourceDefinitions.php
+++ /dev/null
@@ -1,245 +0,0 @@
-<?php
-/**
- * Copyright (c) 2012, Agence Française Informatique (AFI). All rights reserved.
- *
- * BOKEH is free software; you can redistribute it and/or modify
- * it under the terms of the GNU AFFERO GENERAL PUBLIC LICENSE as published by
- * the Free Software Foundation.
- *
- * There are special exceptions to the terms and conditions of the AGPL as it
- * is applied to this software (see README file).
- *
- * BOKEH is distributed in the hope that it will be useful,
- * but WITHOUT ANY WARRANTY; without even the implied warranty of
- * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
- * GNU AFFERO GENERAL PUBLIC LICENSE for more details.
- *
- * You should have received a copy of the GNU AFFERO GENERAL PUBLIC LICENSE
- * along with BOKEH; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301  USA
- */
-
-class ZendAfi_Controller_Action_RessourceDefinitions {
-  protected $_definitions;
-
-  public function __construct($definitions_array) {
-    $this->_definitions = $definitions_array;
-  }
-
-
-  public function getModelLoader() {
-    return Storm_Model_Abstract::getLoaderFor($this->getModelClass());
-  }
-
-
-  public function find($id) {
-    return $this->getModelLoader()->find($id);
-  }
-
-
-  public function findAll($request) {
-    return $this->findAllBy($this->_addScopeParam([], $request));
-  }
-
-
-  public function findAllBy($params) {
-    return call_user_func([$this->getModelLoader(),
-                           $this->getFindAllMethod()],
-                          array_merge(['order' => $this->getOrder()],
-                                      $params));
-  }
-
-
-  protected function _addScopeParam($params, $request) {
-    $closure = function($item, $value) use (&$params) {
-      $params[$item] = $value;
-    };
-
-    $this->withScopeDo($closure, $request);
-    return $params;
-  }
-
-
-  public function withScopeDo($closure, $request) {
-    if (!$this->hasScope())
-      return;
-
-    $scope = $this->getScope();
-    if (!is_array($scope))
-      $scope = [$scope];
-
-    foreach($scope as $item)
-      if ($value = $request->getParam($item))
-        $closure($item, $value);
-  }
-
-
-  public function newModel() {
-    return $this->getModelLoader()->newInstance();
-  }
-
-
-  public function doAfterAdd($model) {
-    if (isset($this->_definitions['after_add']))
-      $this->_definitions['after_add']($model);
-  }
-
-
-  public function doAfterEdit($model) {
-    if (isset($this->_definitions['after_edit']))
-      $this->_definitions['after_edit']($model);
-  }
-
-
-  public function doAfterDelete($model) {
-    if (isset($this->_definitions['after_delete']))
-      $this->_definitions['after_delete']($model);
-  }
-
-
-  public function successfulDeleteMessage($model) {
-    return sprintf($this->_definitions['messages']['successful_delete'],
-                   $model->getLibelle());
-  }
-
-
-  public function successfulSaveMessage($model) {
-    return sprintf($this->_definitions['messages']['successful_save'],
-                   $model->getLibelle());
-  }
-
-
-  public function successfulAddMessage($model) {
-    if (isset($this->_definitions['messages']['successful_add']))
-      $successfull_add = $this->_definitions['messages']['successful_add'];
-    else
-      $successfull_add = $this->_definitions['messages']['successful_save'];
-
-    return sprintf($successfull_add, $model->getLibelle());
-  }
-
-
-  public function indexActionTitle() {
-    return $this->titleForAction('index');
-  }
-
-
-  public function titleForAction($action) {
-    if (isset($this->_definitions['actions'][$action]['title']))
-      return $this->_definitions['actions'][$action]['title'];
-    return '';
-  }
-
-
-  public function editActionTitle($model) {
-    return sprintf($this->titleForAction('edit'),$model->getLibelle());
-  }
-
-
-  public function addActionTitle() {
-    return $this->titleForAction('add');
-  }
-
-
-  public function getModelClass() {
-    return $this->_definitions['model']['class'];
-  }
-
-
-  public function getModelId() {
-    return $this->_definitions['model']['model_id'];
-  }
-
-
-  public function getOrder() {
-    if (isset($this->_definitions['model']['order']))
-      return $this->_definitions['model']['order'];
-    return 'libelle';
-  }
-
-
-  public function getFindAllMethod() {
-    if (isset($this->_definitions['model']['findAll']))
-      return $this->_definitions['model']['findAll'];
-    return 'findAllBy';
-  }
-
-
-  public function getScope() {
-    if (isset($this->_definitions['model']['scope']))
-      return $this->_definitions['model']['scope'];
-    return null;
-  }
-
-
-  public function hasScope() {
-    $scope = $this->getScope();
-    return !empty($scope);
-  }
-
-
-  public function getModelName() {
-    return $this->_definitions['model']['name'];
-  }
-
-
-  public function pluralizeModelName() {
-    return Storm_Inflector::pluralize($this->getModelName());
-  }
-
-
-  public function addFormElements($form) {
-    $element_definitions = $this->getFormElementDefinitions();
-
-    foreach($element_definitions as $name => $definition) {
-      $options = isset($definition['options']) ? $definition['options'] : array();
-
-      $form->addElement($definition['element'], $name, $options);
-
-      if ($label = $form->getElement($name)->getDecorator('label'))
-        $label->setOption('escape', false);
-    }
-    return $this;
-  }
-
-
-  public function getDisplayGroups() {
-    if (isset($this->_definitions['display_groups']))
-      return $this->_definitions['display_groups'];
-    return [];
-  }
-
-
-  public function getForm() {
-    if (isset($this->_definitions['form']))
-      return $this->_definitions['form'];
-    return null;
-  }
-
-
-  public function getFormClassName() {
-    if (isset($this->_definitions['form_class_name']))
-      return $this->_definitions['form_class_name'];
-    return null;
-  }
-
-
-  public function setFormClassName($name) {
-    $this->_definitions['form_class_name'] = $name;
-    return $this;
-  }
-
-
-  public function sort($instances) {
-    if (isset($this->_definitions['sort']))
-      usort($instances, $this->_definitions['sort']);
-    return $instances;
-  }
-
-
-  public function getModelActions() {
-    return isset($this->_definitions['model_actions'])
-      ? $this->_definitions['model_actions']
-      : [];
-  }
-}
\ No newline at end of file
diff --git a/library/ZendAfi/Controller/Plugin/Abstract.php b/library/ZendAfi/Controller/Plugin/Abstract.php
index 674db67f96d..b55426b0425 100644
--- a/library/ZendAfi/Controller/Plugin/Abstract.php
+++ b/library/ZendAfi/Controller/Plugin/Abstract.php
@@ -116,12 +116,6 @@ abstract class ZendAfi_Controller_Plugin_Abstract {
   }
 
 
-  public function visitDefinitions($definitions) {
-    $this->_definitions = $definitions;
-    return $this;
-  }
-
-
   public function visitRedirectToReferer($callback) {
     $this->_redirect_to_referer = $callback;
     return $this;
-- 
GitLab