public function createAction(Request $request)
{
$doc = new Document();
$roleCurator = $this->getRole('ROLE_FINANCE_CURATOR');
$userApproverCurator = new UserApprover();
$userApproverCurator->setRole($roleCurator);
$userApproverCurator->setDocument($doc);
$roleInitiator = $this->getRole('ROLE_FINANCE_INITIATOR');
$userApproverInitiator = new UserApprover();
$userApproverInitiator->setRole($roleInitiator);
$userApproverInitiator->setDocument($doc);
$doc->getApprovers()->add($userApproverInitiator);
$doc->getApprovers()->add($userApproverCurator);
$form = $this->createForm(DocumentType::class, $doc);
$form->handleRequest($request);
if ( $form->isSubmitted() && $form->isValid() ) {
$em = $this->getDoctrine()->getManager();
foreach ($doc->getApprovers() as $approver){
$em->persist($approver);
}
// ... other code
$em->persist($doc);
$em->flush();
return $this->redirectToRoute('finance_exp_view', ['id' => $doc->getId()]);
}
return $this->render('::doc.create.html.twig', [
'form' => $form->createView()
]);
}
class DocumentType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$builder
->add('name', TextType::class, [
'label' => 'Предмет договора',
])
->add('price', NumberType::class, [
'label' => 'Цена',
'scale' => 2,
'grouping' => NumberFormatter::GROUPING_USED
])
// ... other fields
->add('approvers', CollectionType::class, [
'entry_type' => ApproverType::class
]);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => Document::class,
));
}
}
class ApproverType extends AbstractType
{
public function buildForm(FormBuilderInterface $builder, array $options)
{
$listener = function (FormEvent $event) use($builder) {
/** @var UserApprover $approver */
if (!$approver = $event->getData()) {
return;
}
$form = $event->getForm();
$form->add('user', EntityType::class, [
'class' => 'AppBundle:User',
'label' => $approver->getRole()->getTitle(),
'choice_label' => function ($user) {
/** @var User $user */
$absent = (!$user->getAbsent()) ? '' : ' (отсутствует)';
return $user->getFullName() . $absent;
},
'query_builder' => function (EntityRepository $er) use ($approver){
$qb = $er->createQueryBuilder('u')
->innerJoin('u.userRoles','r')
->where('r.name=?1')
->setParameter(1, $approver->getRole()->getName())
->orderBy('u.lastName', 'ASC')
;
return $qb;
},
'placeholder' => '--- Выберите ---'
]);
};
$builder->addEventListener(FormEvents::PRE_SET_DATA, $listener);
}
public function configureOptions(OptionsResolver $resolver)
{
$resolver->setDefaults(array(
'data_class' => Approver::class,
));
}
}
<?php
namespace Finance\ExpBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* Document
*
* @ORM\Table(name="exp_document", indexes={@ORM\Index(name="tasks_user_id_index", columns={"initiator_id"})})
* @ORM\Entity(repositoryClass="Finance\ExpBundle\Repository\DocumentRepository")
*/
class Document
{
/**
* @var integer
*
* @ORM\Column(name="initiator_id", type="integer", nullable=false)
*/
private $initiatorId;
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var \DateTime
*
* @ORM\Column(name="created_at", type="datetime", nullable=true)
*/
private $createdAt;
/**
* @var \DateTime
*
* @ORM\Column(name="updated_at", type="datetime", nullable=true)
*/
private $updatedAt;
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* One Customer has One Cart.
* @var DocStatus
* @ORM\OneToOne(targetEntity="DocStatus", mappedBy="document")
*/
private $docStatus;
/**
* @return DocStatus
*/
public function getDocStatus()
{
return $this->docStatus;
}
/**
* @return Status
*/
public function getStatus()
{
return $this->getDocStatus()->getStatus();
}
/**
* Set initiatorId
*
* @param integer $initiatorId
*
* @return Document
*/
public function setInitiatorId($initiatorId)
{
$this->initiatorId = $initiatorId;
return $this;
}
/**
* Get initiatorId
*
* @return integer
*/
public function getInitiatorId()
{
return $this->initiatorId;
}
/**
* Set name
*
* @param string $name
*
* @return Document
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set createdAt
*
* @param \DateTime $createdAt
*
* @return Document
*/
public function setCreatedAt($createdAt)
{
$this->createdAt = $createdAt;
return $this;
}
/**
* Get createdAt
*
* @return \DateTime
*/
public function getCreatedAt()
{
return $this->createdAt;
}
/**
* Set updatedAt
*
* @param \DateTime $updatedAt
*
* @return Document
*/
public function setUpdatedAt($updatedAt)
{
$this->updatedAt = $updatedAt;
return $this;
}
/**
* Get updatedAt
*
* @return \DateTime
*/
public function getUpdatedAt()
{
return $this->updatedAt;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}
<?php
namespace Finance\ExpBundle\Entity;
use Doctrine\Common\Collections\ArrayCollection;
use Doctrine\ORM\Mapping as ORM;
/**
* DocStatus
*
* @ORM\Table(name="exp_doc_status", indexes={@ORM\Index(name="id_doc", columns={"id_doc"}), @ORM\Index(name="id_status", columns={"id_status"})})
* @ORM\Entity
*/
class DocStatus
{
/**
* @var \DateTime
*
* @ORM\Column(name="event_date", type="datetime", nullable=false)
*/
private $eventDate = 'CURRENT_TIMESTAMP';
/**
* @var integer
*
* @ORM\Column(name="event_day", type="integer", nullable=false)
*/
private $eventDay = '0';
/**
* @var integer
*
* @ORM\Id
* @ORM\GeneratedValue(strategy="NONE")
*/
private $idDoc;
/**
* @ORM\OneToOne(targetEntity="Document", inversedBy="docStatus")
* @ORM\JoinColumn(name="id_doc", referencedColumnName="id")
*/
private $document;
/**
* @ORM\ManyToOne(targetEntity="Status", inversedBy="docStatus")
* @ORM\JoinColumn(name="id_status", referencedColumnName="id")
*/
private $status;
public function getStatus()
{
return $this->status;
}
public function getDocument()
{
return $this->document;
}
/**
* @var integer
* @ORM\Id
* @ORM\Column(name="id_status", type="integer", nullable=false)
*/
private $idStatus;
/**
* Set eventDate
*
* @param \DateTime $eventDate
*
* @return DocStatus
*/
public function setEventDate($eventDate)
{
$this->eventDate = $eventDate;
return $this;
}
/**
* Get eventDate
*
* @return \DateTime
*/
public function getEventDate()
{
return $this->eventDate;
}
/**
* Set eventDay
*
* @param integer $eventDay
*
* @return DocStatus
*/
public function setEventDay($eventDay)
{
$this->eventDay = $eventDay;
return $this;
}
/**
* Get eventDay
*
* @return int
*/
public function getEventDay()
{
return $this->eventDay;
}
/**
* Get idDoc
*
* @return \Finance\ExpBundle\Entity\Document
*/
public function getIdDoc()
{
return $this->idDoc;
}
}
<?php
namespace Finance\ExpBundle\Entity;
use Doctrine\ORM\Mapping as ORM;
/**
* Status
*
* @ORM\Table(name="exp_status")
* @ORM\Entity
*/
class Status
{
/**
* @var string
*
* @ORM\Column(name="name", type="string", length=255, nullable=false)
*/
private $name;
/**
* @var integer
*
* @ORM\Column(name="day_by_reglament", type="integer", nullable=false)
*/
private $dayByReglament = '0';
/**
* @var integer
*
* @ORM\Column(name="id", type="integer")
* @ORM\Id
* @ORM\GeneratedValue(strategy="IDENTITY")
*/
private $id;
/**
* @ORM\OneToMany(targetEntity="DocStatus", mappedBy="status")
*/
private $docStatus;
public function getDocStatus()
{
return $this->docStatus;
}
/**
* Set name
*
* @param string $name
*
* @return Status
*/
public function setName($name)
{
$this->name = $name;
return $this;
}
/**
* Get name
*
* @return string
*/
public function getName()
{
return $this->name;
}
/**
* Set dayByReglament
*
* @param integer $dayByReglament
*
* @return Status
*/
public function setDayByReglament($dayByReglament)
{
$this->dayByReglament = $dayByReglament;
return $this;
}
/**
* Get dayByReglament
*
* @return integer
*/
public function getDayByReglament()
{
return $this->dayByReglament;
}
/**
* Get id
*
* @return integer
*/
public function getId()
{
return $this->id;
}
}
$em = $this->getDoctrine();
$repoDoc = $em->getRepository(Document::class);
$doc = $repoDoc->find($id);
dump($doc->getStatus()->getName());
dump($doc->getStatus()->getDayByReglament());
{{ dump(doc.status.name) }}
{{ dump(doc.status.dayByReglament) }}
.separator *.line {
-fx-border-style: solid;
-fx-border-width: 0 0 1 0; /* фишка в задании толщины только одному из бордюров */
-fx-border-color: red;
}
var start = new Date();
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'epr'
});
for (var i = 0; i < 1000; i++) {
connection.query(
'SELECT * FROM dreg_document',
function(error, result, fields){
var str = '';
result.forEach(function(row){
str += ' ' + row.id + ' ';
});
console.log(str);
}
);
}
connection.end();
var end = new Date();
console.log('node.js %d мс', (end.getTime()-start.getTime()) / 1000);
client.send('qwerty');
client.send('qwerty');
console.log(str);
// начало выполнения скрипта
var start = new Date();
// счетчик обращений к БД
var ConnCountGlobal = 0;
// Число обращений к БД
var iLength = 100;
var connection = mysql.createConnection({
host : 'localhost',
user : 'root',
password : '',
database : 'epr'
});
for (var i = 0; i < iLength; i++) {
connection.query(
'SELECT * FROM dreg_document',
function(error, result, fields){
// для последнего запроса вычисляем таймер
if (ConnCountGlobal == iLength-1){
var dateObj = new Date();
var currTime = dateObj.getTime();
console.log(' node.js - %d мс', (currTime-start.getTime()) / 1000);
}
ConnCountGlobal++;
}
);
}
connection.end();
<proxies>
<proxy>
<active>true</active>
<protocol>http</protocol>
<username>marchenko_am@domain.ru</username>
<password>1</password>
<host>192.168.0.31</host>
<port>8080</port>
<nonProxyHosts>local.net|domain.ru</nonProxyHosts>
</proxy>
</proxies>
<?xml version="1.0" encoding="utf-8"?>
<x:stylesheet version="1.0"
xmlns:atom="http://www.w3.org/2005/Atom"
xmlns:x="http://www.w3.org/1999/XSL/Transform">
<x:output
method="html"
media-type="text/html"
indent="yes"
encoding="UTF-8"/>
<x:template match="/atom:feed">
<x:text disable-output-escaping='yes'><!DOCTYPE html></x:text>
<html>
<head>
<title>DOCTYPE html 5</title>
</head>
<body>
<x:for-each select="atom:entry">
<x:sort order="descending" select="."/>
<h2>бла бла бла</h2>
Опубликовано: <x:value-of select="atom:published"/><br />
</x:for-each>
</body>
</html>
</x:template>
</x:stylesheet>