示例#1
0
 /**
  * Finds the CsObjects model based on its primary key value.
  * If the model is not found, a 404 HTTP exception will be thrown.
  * @param integer $id
  * @return CsObjects the loaded model
  * @throws NotFoundHttpException if the model cannot be found
  */
 protected function findModel($id)
 {
     if (($model = CsObjects::findOne($id)) !== null) {
         return $model;
     } else {
         throw new NotFoundHttpException('The requested page does not exist.');
     }
 }
示例#2
0
 /**
  * Izlistava sve specifikacije izabranih predmeta usluga i modela predmeta.
  */
 protected function objectProperties($service, $object_models, $products)
 {
     if ($object_models != null or $products != null or $service->serviceObjectProperties != null) {
         /*$object = $service->object;
           $class = $object->class;
           $level = $object->level;*/
         // if part: parts properties + container's own and inherited properties + container model/product properties
         /*if($class=='part'){
               $part = $object;
               $container = $service->partContainer;
           }*/
         // if model: models properties + objects public/protected properties + inherited properties // filtered through services object properties
         $objectProperties = [];
         if ($object_models and count($object_models) == 1) {
             foreach ($object_models as $object_model) {
                 $object_m = \common\models\CsObjects::findOne($object_model);
                 if ($object_m and $object_m->objectProperties) {
                     foreach ($object_m->objectProperties as $object_mProperty) {
                         //if(!in_array($object_mProperty->id, $objectSpecification)){
                         $objectProperties[] = $object_mProperty;
                         //}
                     }
                 }
             }
         }
         if ($service->serviceObjectProperties != null) {
             foreach ($service->serviceObjectProperties as $serviceObjectProperty) {
                 // all servicespecs
                 // we need only specs for this service and this/these object_models
                 if (!in_array($serviceObjectProperty->object_property_id, $objectProperties)) {
                     $objectProperties[] = $serviceObjectProperty->objectProperty;
                 }
             }
         }
         // if object: object's and inherited properties // filtered through services object properties
         // if products: product properties + inherited + object's and inherited properties // filtered through services object properties
         // filtered through services object properties
         /*if ($object = $service->object) {
               if ($object->objectProperties) {
                   foreach($object->objectProperties as $objectProperty) {
                       if($objectProperty->property_class!='private'){
                           $objectSpecification[] = $objectProperty->id;
                       }                                                                                          
                   }
               }           
           }
           
           if(isset($objectSpecification) and $objectSpecification) {
               
           }*/
     }
     return isset($objectProperties) ? $objectProperties : null;
 }
 /**
  * Lists all CsServices models.
  * @return mixed
  */
 public function actionIndex()
 {
     $request = Yii::$app->request;
     $post = $request->post('CsServicesSearch');
     // industry
     if (isset($post['industry_id']) && $post['industry_id'] != null && $post['industry_id'] != '') {
         $industry = CsIndustries::findOne($post['industry_id']);
         return $this->redirect(['/services/i/' . slug($industry->tName)]);
     }
     // object
     if (isset($post['object_id']) && $post['object_id'] != null && $post['object_id'] != '') {
         $object = CsObjects::findOne($post['object_id']);
         return $this->redirect(['/services/o/' . slug($object->tName)]);
     }
     // product
     if (isset($post['product_id']) && $post['product_id'] != null && $post['product_id'] != '') {
         $product = CsProducts::findOne($post['product_id']);
         return $this->redirect(['/services/p/' . slug($product->name)]);
     }
     // action
     if (isset($post['action_id']) && $post['action_id'] != null && $post['action_id'] != '') {
         $action = CsActions::findOne($post['action_id']);
         return $this->redirect(['/services/a/' . slug($action->tName)]);
     }
     // service
     if (isset($post['id']) && $post['id'] != null && $post['id'] != '') {
         $service = CsServices::findOne($post['id']);
         return $this->redirect(['/s/' . slug($service->tName)]);
     }
     // tags
     if (isset($post['tag_id']) && $post['tag_id'] != null && $post['tag_id'] != '') {
         $tag = CsTags::findOne($post['tag_id']);
         switch ($tag->entity) {
             case 'action':
                 return $this->redirect(['/services', 'a' => $tag->entity_id]);
                 break;
             case 'object':
                 return $this->redirect(['/services', 'o' => $tag->entity_id]);
                 break;
             case 'industry':
                 return $this->redirect(['/services', 'i' => $tag->entity_id]);
                 break;
             case 'service':
                 $service = CsServices::findOne($tag->entity_id);
                 return $this->redirect(['/s/' . slug($service->tName)]);
                 break;
             default:
                 return $this->redirect(['/services']);
                 break;
         }
     }
     if (isset($post['name']) && $post['name'] != null && $post['name'] != '') {
         return $this->redirect(['/services', 'q' => $post['name']]);
     }
 }