public function loadActionClass()
 {
     if (array_key_exists(0, $this->url_array) && !empty($this->url_array[0])) {
         if (RedBean_Plugin_Finder::where("bites", " name = :module and status = 1", array(":module" => $this->url_array[0]))) {
             $this->module = array_shift($this->url_array);
         }
     }
     // Include the module actions class
     if (file_exists(sprintf('%s/bites/%s/actions.%s.class.php', ROOT, $this->module, APP))) {
         include sprintf('%s/bites/%s/actions.%s.class.php', ROOT, $this->module, APP);
     } else {
         header('Location: /oops-cannot-find-page');
         exit;
     }
 }
Example #2
0
 /**
  * Returns a collection of Domain Objects.
  * @param string $type
  * @param string $query
  * @return array $collection
  */
 public static function getDomainObjects($type, $query = "1", $values = array())
 {
     //Fetch us a toolbox.
     $tools = RedBean_Setup::getToolBox();
     $redbean = $tools->getRedBean();
     $domainObject = new $type();
     $typeName = $domainObject->bean->getMeta("type");
     $collection = array();
     $finder = new \RedBean_Plugin_Finder();
     $beans = $finder->where($typeName, $query, $values);
     foreach ($beans as $bean) {
         $domainObject = new $type();
         $domainObject->bean = $bean;
         $collection[] = $domainObject;
     }
     return $collection;
 }
Example #3
0
	/**
	 * Finds a bean using a type and a where clause (SQL).
	 * As with most Query tools in RedBean you can provide values to
	 * be inserted in the SQL statement by populating the value
	 * array parameter; you can either use the question mark notation
	 * or the slot-notation (:keyname).
	 * The variation also exports the beans (i.e. it returns arrays).
	 *
	 * @param string $type   type
	 * @param string $sql    sql
	 * @param array  $values values
	 *
	 * @return array $arrays arrays
	 */
	public static function findAndExport($type, $sql="1", $values=array()) {
		$items = RedBean_Plugin_Finder::where( $type, $sql, $values );
		$arr = array();
		foreach($items as $key=>$item) {
			$arr[$key]=$item->export();
		}
		return $arr;
	}
 private function checkDependencies($name)
 {
     $dependencies = \R::getAll("select depends_on from dependencies where name = '{$name}'");
     $dependents = array();
     foreach ($dependencies as $dependent) {
         if (!\RedBean_Plugin_Finder::where('bites', 'name = :name and status = 1', array(':name' => $dependent['depends_on']))) {
             $dependents[] = ucfirst($dependent['depends_on']) . ' is not installed';
         }
     }
     if (!empty($dependents)) {
         return $dependents;
     }
     return false;
 }