/** * @param Producer $producer * * @throws Exception\FacadeException */ public static function addProducer(Producer $producer) { $appId = $producer->getAppId(); if (array_key_exists($appId, static::$producers)) { throw new Exception\FacadeException("Producer with {$appId} already exists!"); } static::$producers[$appId] = $producer; }
public function actionAdmin() { $model = new Producer('search'); $model->unsetAttributes(); if (isset($_GET['Producer'])) { $model->setAttributes($_GET['Producer']); } $this->render('admin', array('model' => $model)); }
/** * Publish RPC response * * @param Message $message Message * @param mixed $response RPC response */ private function publishRpcResponse(Message $message, $response) { $options = array(); if ($message->hasRpcChannelExpire()) { $options = array('channelExpire' => $message->getRpcChannelExpire()); } $producer = new Producer($message->getRpcChannel(), $this->connection, $options); $response = new Message($response); $response->setRequestId($message->getRequestId()); $producer->publish($response); }
public function testConsume() { $this->markTestSkipped('Fails on CI'); $producer = new Producer(); $producer->addBrokers('localhost:9092'); /** @var ProducerTopic $producerTopic */ $producerTopic = $producer->newTopic('test'); $producerTopic->produce(self::PARTITION, 0, 'test message'); $this->consumerTopic->consumeStart(self::PARTITION, RD_KAFKA_OFFSET_BEGINNING); $message = $this->consumerTopic->consume(self::PARTITION, 1000); $this->consumerTopic->consumeStop(self::PARTITION); $this->assertInstanceOf(Message::class, $message); }
public function setUp() { $producer = new Producer(); $producer->addBrokers('localhost:9092'); /** @var ProducerTopic $producerTopic */ $producerTopic = $producer->newTopic('test'); $producerTopic->produce(RD_KAFKA_PARTITION_UA, self::PARTITION, 'test message 2', 'key_2'); $consumer = new Consumer(); $consumer->addBrokers('localhost:9092'); /** @var ConsumerTopic $consumerTopic */ $consumerTopic = $consumer->newTopic('test'); $consumerTopic->consumeStart(self::PARTITION, self::OFFSET); $this->message = $consumerTopic->consume(self::PARTITION, 1000); $consumerTopic->consumeStop(self::PARTITION); }
/** * @param StoreCategory $category * @param CDbCriteria $mergeWith * @return array|mixed|null */ public function getForCategory(StoreCategory $category, CDbCriteria $mergeWith) { $criteria = new CDbCriteria(['order' => 't.sort ASC', 'join' => 'LEFT JOIN {{store_product}} AS products ON products.producer_id = t.id', 'distinct' => true]); $criteria->addInCondition('products.category_id', [$category->id]); $criteria->mergeWith($mergeWith); return Producer::model()->findAll($criteria); }
public function actionView($slug) { $producer = Producer::model()->getBySlug($slug); if (!$producer) { throw new CHttpException(404, Yii::t('StoreModule.store', 'Page not found!')); } $this->render('view', ['brand' => $producer, 'products' => $this->productRepository->getByBrandProvider($producer)]); }
public function loadModel($id) { $model = Producer::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('StoreModule.store', 'Page not found!')); } return $model; }
public function loadModel($id) { $model = Producer::model()->findByPk($id); if ($model === null) { throw new CHttpException(404, Yii::t('StoreModule.producer', 'Запрошенная страница не найдена.')); } return $model; }
/** * @throws CException */ public function run() { $criteria = new CDbCriteria(['limit' => $this->limit, 'order' => $this->order, 'scopes' => ['published']]); if (null === $this->category) { $producers = Producer::model()->findAll($criteria); } else { $producers = $this->producerRepository->getForCategory($this->category, $criteria); } $this->render($this->view, ['producers' => $producers]); }
/** * Instantiate and return a resolvable wrapping the passed object. * * @param Producer|mixed $object * @param string $what * * @return Producible */ function produce($object, $what) { $collection = null; if ($object instanceof Collection) { $collection = $object->all(); } elseif (is_array($object)) { $collection = $object; } if (!is_null($collection)) { $objects = []; foreach ($collection as $item) { $objects[] = produce($item, $what); } if ($object instanceof Collection) { return new Collection($objects); } return $objects; } return $object->produce($what); }
<?php require_once "Producer.php"; $producer = new Producer(); $producer->setNameOfProducer('WTI'); echo $producer->getNameOfProducer();
/** * @throws CException */ public function run() { $criteria = new CDbCriteria(['limit' => $this->limit, 'order' => $this->order, 'scopes' => ['published']]); $this->render($this->view, ['brands' => $this->category ? $this->producerRepository->getForCategory($this->category, $criteria) : Producer::model()->findAll($criteria), 'title' => $this->title]); }
/** * Tests the <code>produce()</code> method with a connection error. * * @expectedException \RuntimeException */ public function testProduce_NoConnection() { $producer = new Producer('invalid', 4444); $producer->produce('default', 'foobar'); }
<?php /** * Created by PhpStorm. * User: Jenner * Date: 2015/8/19 * Time: 14:32 */ declare (ticks=1); require dirname(dirname(dirname(__FILE__))) . DIRECTORY_SEPARATOR . 'vendor' . DIRECTORY_SEPARATOR . 'autoload.php'; class Producer extends \Jenner\SimpleFork\Process { public function run() { for ($i = 0; $i < 100; $i++) { $this->queue()->put(1, $i); //usleep(50000); } } } $queue = new \Jenner\SimpleFork\Queue\SystemVMessageQueue(1, "/tmp/simple-fork-test.ipc"); $producer = new Producer(); $producer->queue($queue); $producer->start(); $producer->wait();
<b><?php echo CHtml::encode($data->getAttributeLabel('sum')); ?> :</b> <?php echo CHtml::encode($data->sum); ?> <br /> <b><?php echo CHtml::encode($data->getAttributeLabel('id_producer')); ?> :</b> <?php echo CHtml::encode(Producer::items($data->id_producer)); //echo CHtml::encode($data->id_producer); ?> <br /> <b><?php echo CHtml::encode($data->getAttributeLabel('material')); ?> :</b> <?php echo CHtml::encode($data->material); ?> <br /> <b><?php echo CHtml::encode($data->getAttributeLabel('color')); ?>
/** * @param Producer $producer * @param int $width * @param int $height * @param bool|true $crop * @return mixed */ public static function producer(Producer $producer, $width = 0, $height = 0, $crop = true) { return $producer->getImageUrl($width, $height, $crop, static::getDefaultImage()); }
public function getFormattedList() { return CHtml::listData(Producer::model()->findAll(), 'id', 'name_short'); }
public function run() { $this->render($this->view, ['producers' => Producer::model()->published()->cache($this->cacheTime)->findAll()]); }
<?php require_once __DIR__ . '/job.php'; require_once __DIR__ . '/producer.php'; $job = new HelloWorldJob("Christoph"); $producer = new Producer(); $producer->push($job);
# # GET https://<endpoint>/Producer/LoginNameCheck/[LoginName] # $app->get('/LoginNameCheck/:LoginName', function ($LoginName) use($app) { $producer = new Producer($app); echo $producer->checkLoginName($LoginName); }); # # ũ����ע�ᡪ���Ͷ�����֤�� # # POST https://<endpoint>/Producer/SmsCode/ # # Request Body # { # "Telephone":"�绰" # } # $app->post('/SmsCode/', function () use($app) { $producer = new Producer($app); echo $producer->postSmsCode(); }); # # ũ����ע�ᡪ��֤������ # # GET https://<endpoint>/Producer/SmsCode/[SmsCodeId]/[UserSmsCode]/[Telephone] # $app->get('/SmsCode/:SmsCodeId/:UserSmsCode/:Telephone', function ($SmsCodeId, $UserSmsCode, $Telephone) use($app) { $producer = new Producer($app); echo $producer->verifySmsCode($SmsCodeId, $UserSmsCode, $Telephone); }); });
<?php echo $form->labelEx($model, 'width'); ?> <?php echo $form->textField($model, 'width', array('placeholder' => 'in inches')); ?> <?php echo $form->error($model, 'width'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'producer_id'); ?> <?php echo $form->dropDownList($model, 'producer_id', GxHtml::listDataEx(Producer::model()->findAllAttributes(null, true))); ?> <?php echo $form->error($model, 'producer_id'); ?> </div><!-- row --> <div class="row"> <?php echo $form->labelEx($model, 'price'); ?> <?php echo $form->textField($model, 'price', array('placeholder' => 'in Rs.')); ?> <?php echo $form->error($model, 'price'); ?>
public function run() { $criteria = new CDbCriteria(); $criteria->select = 'inkind'; $criteria->distinct = true; $t['unselectValue'] = NULL; $this->inkind = Inkind::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->inkind); $i++) { $t[$this->inkind[$i]->inkind] = $this->inkind[$i]->inkind; } $t['unselectValue'] = ''; $this->inkind = $t; $t = []; // var_dump($this->inkind); $criteria = new CDbCriteria(); $criteria->select = 'kindparent'; $criteria->distinct = true; $t['unselectValue'] = NULL; $this->kindparent = Kindparent::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->kindparent); $i++) { $t[$this->kindparent[$i]->kindparent] = $this->kindparent[$i]->kindparent; } $this->kindparent = $t; $t = []; // var_dump($this->kindparent); $criteria = new CDbCriteria(); $criteria->select = 'producer'; $criteria->distinct = true; //$t['uncheckValue']=NULL; $this->producer = Producer::model()->findAll($criteria); //var_dump($this->inkind); for ($i = 0; $i < count($this->producer); $i++) { $t[$this->producer[$i]->producer] = $this->producer[$i]->producer; } $this->producer = $t; $t = []; $form = new ProductSelectForm(); $form->clearErrors(); if (isset($_POST['ProductSelectForm'])) { $form->attributes = $_POST['ProductSelectForm']; } // if (isset($_POST['ProductSelectForm'])) { // $form->kindparent=$_POST['ProductSelectForm']['kindparent']; // $form->inkind=$_POST['ProductSelectForm']['inkind']; // $form->producer=$_POST['ProductSelectForm']['producer'];} //$form->min=$_POST['ProductSelectForm']['min']; //$form->max=$_POST['ProductSelectForm']['max']; // var_dump($_POST['ProductSelectForm']); // } //var_dump($_POST); // var_dump($form->validate()); // if (isset($_POST['ProductSelectForm'])&&(!$form->validate())) { // unset($_POST['SiteSearchForm']); // $form->clearErrors(); // $form->addError('ProductSelectForm','Задайте условия поиска'); // $z=$form->getErrors(); // var_dump($z); // } // } // var_dump($_GET); $this->render('productSelect', array('form' => $form, 'inkind' => $this->inkind, 'kindparent' => $this->kindparent, 'producer' => $this->producer)); $form->clearErrors(); }
<div class="row"> <?php echo $form->label($model, 'width'); ?> <?php echo $form->textField($model, 'width'); ?> </div> <div class="row"> <?php echo $form->label($model, 'producer_id'); ?> <?php echo $form->dropDownList($model, 'producer_id', GxHtml::listDataEx(Producer::model()->findAllAttributes(null, true)), array('prompt' => Yii::t('app', 'All'))); ?> </div> <div class="row"> <?php echo $form->label($model, 'price'); ?> <?php echo $form->textField($model, 'price'); ?> </div> <div class="row"> <?php echo $form->label($model, 'status');
<?php require_once '../../config/config.php'; require_once '../../lib/Thumper/Producer.php'; require_once '../../lib/php-amqplib/amqp.inc'; $producer = new Producer(HOST, PORT, USER, PASS, VHOST); $producer->setExchangeOptions(array('name' => 'logs-exchange', 'type' => 'topic')); $producer->publish($argv[1], sprintf('%s.%s', $argv[2], $argv[3]));
/** * @throws CException */ public function run() { $this->render($this->view, ['producers' => Producer::model()->published()->findAll(['limit' => $this->limit])]); }
<div class="col-sm-3"> <br/> <?php echo $form->checkBoxGroup($model, 'is_special'); ?> </div> </div> <div class="row"> <div class="col-sm-4"> <?php echo $form->dropDownListGroup($model, 'category_id', ['widgetOptions' => ['data' => StoreCategoryHelper::formattedList(), 'htmlOptions' => ['empty' => '---', 'encode' => false]]]); ?> </div> <div class="col-sm-3"> <?php echo $form->dropDownListGroup($model, 'producer_id', ['widgetOptions' => ['data' => Producer::model()->getFormattedList(), 'htmlOptions' => ['empty' => '---']]]); ?> </div> </div> <div class="row"> <div class="col-sm-7"> <?php echo $form->textFieldGroup($model, 'name'); ?> </div> </div> <div class="row"> <div class="col-sm-7"> <?php echo $form->slugFieldGroup($model, 'slug', ['sourceAttribute' => 'name']); ?>
<?php $this->breadcrumbs = array(Producer::label(2), Yii::t('app', 'Index')); $this->menu = array(array('label' => Yii::t('app', 'Create') . ' ' . Producer::label(), 'url' => array('create')), array('label' => Yii::t('app', 'Manage') . ' ' . Producer::label(2), 'url' => array('admin'))); ?> <h1><?php echo GxHtml::encode(Producer::label(2)); ?> </h1> <?php $this->widget('zii.widgets.CListView', array('dataProvider' => $dataProvider, 'itemView' => '_view'));
<?php echo Yii::t('StoreModule.store', 'Products'); ?> <small><?php echo Yii::t('StoreModule.store', 'administration'); ?> </small> </h1> </div> <?php $this->widget('yupe\\widgets\\CustomGridView', ['id' => 'product-grid', 'sortableRows' => true, 'sortableAjaxSave' => true, 'sortableAttribute' => 'position', 'sortableAction' => '/store/productBackend/sortable', 'type' => 'condensed', 'dataProvider' => $model->search(), 'filter' => $model, 'actionsButtons' => ['add' => CHtml::link(Yii::t('StoreModule.store', 'Add'), ['/store/productBackend/create'], ['class' => 'btn btn-sm btn-success pull-right']), 'copy' => CHtml::link(Yii::t('StoreModule.store', 'Copy'), '#', ['id' => 'copy-products', 'class' => 'btn btn-sm btn-default pull-right', 'style' => 'margin-right: 4px;'])], 'columns' => [['type' => 'raw', 'value' => function ($data) { return CHtml::image(StoreImage::product($data, 40, 40), $data->name, ["width" => 40, "height" => 40, "class" => "img-thumbnail"]); }], ['name' => 'name', 'type' => 'raw', 'value' => function ($data) { return CHtml::link(\yupe\helpers\YText::wordLimiter($data->name, 5), ["/store/productBackend/update", "id" => $data->id]); }], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'sku', 'editable' => ['emptytext' => '---', 'url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'sku', ['class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'producer_id', 'url' => $this->createUrl('/store/productBackend/inline'), 'source' => CMap::mergeArray(['' => '---'], Producer::model()->getFormattedList()), 'editable' => ['emptytext' => '---']], ['name' => 'category_id', 'value' => function ($data) { $categoryList = '<span class="label label-primary">' . (isset($data->category) ? $data->category->name : '---') . '</span>'; foreach ($data->categories as $category) { $categoryList .= '<br>' . $category->name; } return $categoryList; }, 'type' => 'raw', 'filter' => CHtml::activeDropDownList($model, 'category_id', StoreCategoryHelper::formattedList(), ['encode' => false, 'empty' => '', 'class' => 'form-control']), 'htmlOptions' => ['width' => '220px']], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'price', 'value' => function (Product $data) { return round($data->getBasePrice(), 2); }, 'editable' => ['url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'price', ['class' => 'form-control'])], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'discount_price', 'header' => Yii::t('StoreModule.store', 'New price'), 'value' => function (Product $data) { return round($data->getDiscountPrice(), 2); }, 'editable' => ['emptytext' => '---', 'url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'discount_price', ['class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'in_stock', 'header' => Yii::t('StoreModule.store', 'Availability'), 'url' => $this->createUrl('/store/productBackend/inline'), 'source' => $model->getInStockList(), 'options' => [Product::STATUS_IN_STOCK => ['class' => 'label-success'], Product::STATUS_NOT_IN_STOCK => ['class' => 'label-danger']]], ['class' => 'bootstrap.widgets.TbEditableColumn', 'name' => 'quantity', 'value' => function (Product $data) { return $data->quantity; }, 'header' => Yii::t('StoreModule.store', 'Rest'), 'editable' => ['url' => $this->createUrl('/store/productBackend/inline'), 'mode' => 'inline', 'params' => [Yii::app()->getRequest()->csrfTokenName => Yii::app()->getRequest()->csrfToken]], 'filter' => CHtml::activeTextField($model, 'price', ['class' => 'form-control'])], ['class' => 'yupe\\widgets\\EditableStatusColumn', 'name' => 'status', 'url' => $this->createUrl('/store/productBackend/inline'), 'source' => $model->getStatusList(), 'options' => [Product::STATUS_ACTIVE => ['class' => 'label-success'], Product::STATUS_NOT_ACTIVE => ['class' => 'label-info'], Product::STATUS_ZERO => ['class' => 'label-default']]], ['class' => 'yupe\\widgets\\CustomButtonColumn', 'buttons' => ['front_view' => ['visible' => function ($row, $data) { return $data->status == Product::STATUS_ACTIVE; }]]]]]); ?>
public function setUp() { $producer = new Producer(); $producer->addBrokers('localhost:9092'); $this->producerTopic = $producer->newTopic('test'); }