コード例 #1
0
ファイル: PropertyBagTest.php プロジェクト: nelmio/alice
 public function testIsEmpty()
 {
     $bag = new PropertyBag();
     $this->assertTrue($bag->isEmpty());
     $bag = $bag->with(new Property('foo', null));
     $this->assertFalse($bag->isEmpty());
 }
コード例 #2
0
ファイル: PropertyBagTest.php プロジェクト: mattie02/iCal
 /**
  * @todo Use Mocks instead of a real object!
  */
 public function testPropertyAlreadyExistsOnAddingProperty()
 {
     $this->setExpectedException('\\Exception', "Property with name 'propName' already exists");
     $propertyBag = new PropertyBag();
     $propertyBag->add(new Property('propName', ''));
     $propertyBag->add(new Property('propName', ''));
 }
コード例 #3
0
ファイル: SpecificationBag.php プロジェクト: nelmio/alice
 /**
  * Creates a new instance to which the given specs have been merged. In case of conflicts, the existing values are
  * kept.
  * 
  * @param self $specs
  *
  * @return self
  */
 public function mergeWith(self $specs) : self
 {
     $clone = clone $this;
     if (null === $clone->constructor) {
         $clone->constructor = $specs->constructor;
     }
     $clone->properties = $this->properties->mergeWith($specs->properties);
     $clone->calls = $this->calls->mergeWith($specs->calls);
     return $clone;
 }
コード例 #4
0
 public function __construct(&$source = null, $readOnly = false)
 {
     if ($source === null) {
         $source = new stdClass();
         $readOnly = false;
     }
     if (!is_object($source)) {
         throw new Exception('Expected object type', 2000);
     }
     parent::__construct($source, $readOnly);
 }
コード例 #5
0
ファイル: region.php プロジェクト: robertmoss/foodfinder_main
$region = Utility::getRequestVariable('region', 'none');
if ($region == 'none') {
    $errMessage = "Hmm. Something went wrong. No valid region specified.";
} else {
    $stateList = Utility::getTenantProperty($applicationID, $tenantID, $userID, 'enabledStates');
    if (!is_null($stateList)) {
        $stateArray = explode(",", strtoupper($stateList));
        if (!in_array(strtoupper($region), $stateArray)) {
            $errMessage = "That is not a valid region.";
        } else {
            Log::logPageView('region', 0, $region);
        }
    }
}
// retrieve properties for this region
$propertyBag = new PropertyBag($userID, $tenantID);
$bagName = 'region' . $region . 'Properties';
?>
<!DOCTYPE html>
<html xmlns="http://www.w3.org/1999/xhtml">
    <head>
        <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
        <meta name="viewport" content="width=device-width, initial-scale=1" />
        <title><?php 
echo Utility::getTenantProperty($applicationID, $_SESSION['tenantID'], $userID, 'title');
?>
</title>
        <?php 
include "partials/includes.php";
?>
        <link rel="stylesheet" type="text/css" href="static/css/feature.css" />
コード例 #6
0
include dirname(__FILE__) . '/../partials/pageCheck.php';
include_once dirname(__FILE__) . '/../classes/propertyBag.php';
include_once dirname(__FILE__) . '/../classes/service.php';
include_once dirname(__FILE__) . '/../classes/utility.php';
if ($_SERVER['REQUEST_METHOD'] == "POST") {
    // for now, must be an admin to access property bags: will have to update later if we being using propertyBags for things
    // other than system/tenant settings
    if (!$user->hasRole('admin', $tenantID)) {
        Service::returnError('Access denied.', 403, 'propertyBag');
    }
    $json = file_get_contents('php://input');
    $data = json_decode($json);
    if (!$data || !array_key_exists('name', $data)) {
        Service::returnError('PropertyBag name must be specified for an update.', 400, 'propertyBag Service');
    }
    if (!$data || !array_key_exists('properties', $data)) {
        Service::returnError('PropertyBag properties must be specified for an update.', 400, 'propertyBag Service');
    }
    $bagName = $data->{"name"};
    $properties = $data->{"properties"};
    $propertyBag = new PropertyBag($userID, $tenantID);
    foreach ($properties as $property => $value) {
        $propertyBag->putProperty($bagName, $property, $value);
    }
    header("Access-Control-Allow-Origin: *");
    header('Content-Type: application/json');
    echo json_encode($properties);
} else {
    Service::returnError('Method not supported.', 400, 'propertyBag');
}