Merge documentation into mono-repo
3
.gitmodules
vendored
Normal file
@ -0,0 +1,3 @@
|
||||
[submodule "_exts/sphinx-php"]
|
||||
path = _exts/sphinx-php
|
||||
url = https://github.com/fabpot/sphinx-php.git
|
11
.readthedocs.yml
Normal file
@ -0,0 +1,11 @@
|
||||
version: 2
|
||||
|
||||
sphinx:
|
||||
configuration: source/conf.py
|
||||
|
||||
python:
|
||||
version: 3.7
|
||||
install:
|
||||
- requirements: requirements.txt
|
||||
|
||||
|
5
docs/.gitignore
vendored
Normal file
@ -0,0 +1,5 @@
|
||||
_exts
|
||||
build/*
|
||||
!build/git.txt
|
||||
*~
|
||||
.project
|
451
docs/LICENSE
Normal file
@ -0,0 +1,451 @@
|
||||
|
||||
GNU Free Documentation License
|
||||
Version 1.3, 3 November 2008
|
||||
|
||||
|
||||
Copyright (C) 2000, 2001, 2002, 2007, 2008 Free Software Foundation, Inc.
|
||||
<http://fsf.org/>
|
||||
Everyone is permitted to copy and distribute verbatim copies
|
||||
of this license document, but changing it is not allowed.
|
||||
|
||||
0. PREAMBLE
|
||||
|
||||
The purpose of this License is to make a manual, textbook, or other
|
||||
functional and useful document "free" in the sense of freedom: to
|
||||
assure everyone the effective freedom to copy and redistribute it,
|
||||
with or without modifying it, either commercially or noncommercially.
|
||||
Secondarily, this License preserves for the author and publisher a way
|
||||
to get credit for their work, while not being considered responsible
|
||||
for modifications made by others.
|
||||
|
||||
This License is a kind of "copyleft", which means that derivative
|
||||
works of the document must themselves be free in the same sense. It
|
||||
complements the GNU General Public License, which is a copyleft
|
||||
license designed for free software.
|
||||
|
||||
We have designed this License in order to use it for manuals for free
|
||||
software, because free software needs free documentation: a free
|
||||
program should come with manuals providing the same freedoms that the
|
||||
software does. But this License is not limited to software manuals;
|
||||
it can be used for any textual work, regardless of subject matter or
|
||||
whether it is published as a printed book. We recommend this License
|
||||
principally for works whose purpose is instruction or reference.
|
||||
|
||||
|
||||
1. APPLICABILITY AND DEFINITIONS
|
||||
|
||||
This License applies to any manual or other work, in any medium, that
|
||||
contains a notice placed by the copyright holder saying it can be
|
||||
distributed under the terms of this License. Such a notice grants a
|
||||
world-wide, royalty-free license, unlimited in duration, to use that
|
||||
work under the conditions stated herein. The "Document", below,
|
||||
refers to any such manual or work. Any member of the public is a
|
||||
licensee, and is addressed as "you". You accept the license if you
|
||||
copy, modify or distribute the work in a way requiring permission
|
||||
under copyright law.
|
||||
|
||||
A "Modified Version" of the Document means any work containing the
|
||||
Document or a portion of it, either copied verbatim, or with
|
||||
modifications and/or translated into another language.
|
||||
|
||||
A "Secondary Section" is a named appendix or a front-matter section of
|
||||
the Document that deals exclusively with the relationship of the
|
||||
publishers or authors of the Document to the Document's overall
|
||||
subject (or to related matters) and contains nothing that could fall
|
||||
directly within that overall subject. (Thus, if the Document is in
|
||||
part a textbook of mathematics, a Secondary Section may not explain
|
||||
any mathematics.) The relationship could be a matter of historical
|
||||
connection with the subject or with related matters, or of legal,
|
||||
commercial, philosophical, ethical or political position regarding
|
||||
them.
|
||||
|
||||
The "Invariant Sections" are certain Secondary Sections whose titles
|
||||
are designated, as being those of Invariant Sections, in the notice
|
||||
that says that the Document is released under this License. If a
|
||||
section does not fit the above definition of Secondary then it is not
|
||||
allowed to be designated as Invariant. The Document may contain zero
|
||||
Invariant Sections. If the Document does not identify any Invariant
|
||||
Sections then there are none.
|
||||
|
||||
The "Cover Texts" are certain short passages of text that are listed,
|
||||
as Front-Cover Texts or Back-Cover Texts, in the notice that says that
|
||||
the Document is released under this License. A Front-Cover Text may
|
||||
be at most 5 words, and a Back-Cover Text may be at most 25 words.
|
||||
|
||||
A "Transparent" copy of the Document means a machine-readable copy,
|
||||
represented in a format whose specification is available to the
|
||||
general public, that is suitable for revising the document
|
||||
straightforwardly with generic text editors or (for images composed of
|
||||
pixels) generic paint programs or (for drawings) some widely available
|
||||
drawing editor, and that is suitable for input to text formatters or
|
||||
for automatic translation to a variety of formats suitable for input
|
||||
to text formatters. A copy made in an otherwise Transparent file
|
||||
format whose markup, or absence of markup, has been arranged to thwart
|
||||
or discourage subsequent modification by readers is not Transparent.
|
||||
An image format is not Transparent if used for any substantial amount
|
||||
of text. A copy that is not "Transparent" is called "Opaque".
|
||||
|
||||
Examples of suitable formats for Transparent copies include plain
|
||||
ASCII without markup, Texinfo input format, LaTeX input format, SGML
|
||||
or XML using a publicly available DTD, and standard-conforming simple
|
||||
HTML, PostScript or PDF designed for human modification. Examples of
|
||||
transparent image formats include PNG, XCF and JPG. Opaque formats
|
||||
include proprietary formats that can be read and edited only by
|
||||
proprietary word processors, SGML or XML for which the DTD and/or
|
||||
processing tools are not generally available, and the
|
||||
machine-generated HTML, PostScript or PDF produced by some word
|
||||
processors for output purposes only.
|
||||
|
||||
The "Title Page" means, for a printed book, the title page itself,
|
||||
plus such following pages as are needed to hold, legibly, the material
|
||||
this License requires to appear in the title page. For works in
|
||||
formats which do not have any title page as such, "Title Page" means
|
||||
the text near the most prominent appearance of the work's title,
|
||||
preceding the beginning of the body of the text.
|
||||
|
||||
The "publisher" means any person or entity that distributes copies of
|
||||
the Document to the public.
|
||||
|
||||
A section "Entitled XYZ" means a named subunit of the Document whose
|
||||
title either is precisely XYZ or contains XYZ in parentheses following
|
||||
text that translates XYZ in another language. (Here XYZ stands for a
|
||||
specific section name mentioned below, such as "Acknowledgements",
|
||||
"Dedications", "Endorsements", or "History".) To "Preserve the Title"
|
||||
of such a section when you modify the Document means that it remains a
|
||||
section "Entitled XYZ" according to this definition.
|
||||
|
||||
The Document may include Warranty Disclaimers next to the notice which
|
||||
states that this License applies to the Document. These Warranty
|
||||
Disclaimers are considered to be included by reference in this
|
||||
License, but only as regards disclaiming warranties: any other
|
||||
implication that these Warranty Disclaimers may have is void and has
|
||||
no effect on the meaning of this License.
|
||||
|
||||
2. VERBATIM COPYING
|
||||
|
||||
You may copy and distribute the Document in any medium, either
|
||||
commercially or noncommercially, provided that this License, the
|
||||
copyright notices, and the license notice saying this License applies
|
||||
to the Document are reproduced in all copies, and that you add no
|
||||
other conditions whatsoever to those of this License. You may not use
|
||||
technical measures to obstruct or control the reading or further
|
||||
copying of the copies you make or distribute. However, you may accept
|
||||
compensation in exchange for copies. If you distribute a large enough
|
||||
number of copies you must also follow the conditions in section 3.
|
||||
|
||||
You may also lend copies, under the same conditions stated above, and
|
||||
you may publicly display copies.
|
||||
|
||||
|
||||
3. COPYING IN QUANTITY
|
||||
|
||||
If you publish printed copies (or copies in media that commonly have
|
||||
printed covers) of the Document, numbering more than 100, and the
|
||||
Document's license notice requires Cover Texts, you must enclose the
|
||||
copies in covers that carry, clearly and legibly, all these Cover
|
||||
Texts: Front-Cover Texts on the front cover, and Back-Cover Texts on
|
||||
the back cover. Both covers must also clearly and legibly identify
|
||||
you as the publisher of these copies. The front cover must present
|
||||
the full title with all words of the title equally prominent and
|
||||
visible. You may add other material on the covers in addition.
|
||||
Copying with changes limited to the covers, as long as they preserve
|
||||
the title of the Document and satisfy these conditions, can be treated
|
||||
as verbatim copying in other respects.
|
||||
|
||||
If the required texts for either cover are too voluminous to fit
|
||||
legibly, you should put the first ones listed (as many as fit
|
||||
reasonably) on the actual cover, and continue the rest onto adjacent
|
||||
pages.
|
||||
|
||||
If you publish or distribute Opaque copies of the Document numbering
|
||||
more than 100, you must either include a machine-readable Transparent
|
||||
copy along with each Opaque copy, or state in or with each Opaque copy
|
||||
a computer-network location from which the general network-using
|
||||
public has access to download using public-standard network protocols
|
||||
a complete Transparent copy of the Document, free of added material.
|
||||
If you use the latter option, you must take reasonably prudent steps,
|
||||
when you begin distribution of Opaque copies in quantity, to ensure
|
||||
that this Transparent copy will remain thus accessible at the stated
|
||||
location until at least one year after the last time you distribute an
|
||||
Opaque copy (directly or through your agents or retailers) of that
|
||||
edition to the public.
|
||||
|
||||
It is requested, but not required, that you contact the authors of the
|
||||
Document well before redistributing any large number of copies, to
|
||||
give them a chance to provide you with an updated version of the
|
||||
Document.
|
||||
|
||||
|
||||
4. MODIFICATIONS
|
||||
|
||||
You may copy and distribute a Modified Version of the Document under
|
||||
the conditions of sections 2 and 3 above, provided that you release
|
||||
the Modified Version under precisely this License, with the Modified
|
||||
Version filling the role of the Document, thus licensing distribution
|
||||
and modification of the Modified Version to whoever possesses a copy
|
||||
of it. In addition, you must do these things in the Modified Version:
|
||||
|
||||
A. Use in the Title Page (and on the covers, if any) a title distinct
|
||||
from that of the Document, and from those of previous versions
|
||||
(which should, if there were any, be listed in the History section
|
||||
of the Document). You may use the same title as a previous version
|
||||
if the original publisher of that version gives permission.
|
||||
B. List on the Title Page, as authors, one or more persons or entities
|
||||
responsible for authorship of the modifications in the Modified
|
||||
Version, together with at least five of the principal authors of the
|
||||
Document (all of its principal authors, if it has fewer than five),
|
||||
unless they release you from this requirement.
|
||||
C. State on the Title page the name of the publisher of the
|
||||
Modified Version, as the publisher.
|
||||
D. Preserve all the copyright notices of the Document.
|
||||
E. Add an appropriate copyright notice for your modifications
|
||||
adjacent to the other copyright notices.
|
||||
F. Include, immediately after the copyright notices, a license notice
|
||||
giving the public permission to use the Modified Version under the
|
||||
terms of this License, in the form shown in the Addendum below.
|
||||
G. Preserve in that license notice the full lists of Invariant Sections
|
||||
and required Cover Texts given in the Document's license notice.
|
||||
H. Include an unaltered copy of this License.
|
||||
I. Preserve the section Entitled "History", Preserve its Title, and add
|
||||
to it an item stating at least the title, year, new authors, and
|
||||
publisher of the Modified Version as given on the Title Page. If
|
||||
there is no section Entitled "History" in the Document, create one
|
||||
stating the title, year, authors, and publisher of the Document as
|
||||
given on its Title Page, then add an item describing the Modified
|
||||
Version as stated in the previous sentence.
|
||||
J. Preserve the network location, if any, given in the Document for
|
||||
public access to a Transparent copy of the Document, and likewise
|
||||
the network locations given in the Document for previous versions
|
||||
it was based on. These may be placed in the "History" section.
|
||||
You may omit a network location for a work that was published at
|
||||
least four years before the Document itself, or if the original
|
||||
publisher of the version it refers to gives permission.
|
||||
K. For any section Entitled "Acknowledgements" or "Dedications",
|
||||
Preserve the Title of the section, and preserve in the section all
|
||||
the substance and tone of each of the contributor acknowledgements
|
||||
and/or dedications given therein.
|
||||
L. Preserve all the Invariant Sections of the Document,
|
||||
unaltered in their text and in their titles. Section numbers
|
||||
or the equivalent are not considered part of the section titles.
|
||||
M. Delete any section Entitled "Endorsements". Such a section
|
||||
may not be included in the Modified Version.
|
||||
N. Do not retitle any existing section to be Entitled "Endorsements"
|
||||
or to conflict in title with any Invariant Section.
|
||||
O. Preserve any Warranty Disclaimers.
|
||||
|
||||
If the Modified Version includes new front-matter sections or
|
||||
appendices that qualify as Secondary Sections and contain no material
|
||||
copied from the Document, you may at your option designate some or all
|
||||
of these sections as invariant. To do this, add their titles to the
|
||||
list of Invariant Sections in the Modified Version's license notice.
|
||||
These titles must be distinct from any other section titles.
|
||||
|
||||
You may add a section Entitled "Endorsements", provided it contains
|
||||
nothing but endorsements of your Modified Version by various
|
||||
parties--for example, statements of peer review or that the text has
|
||||
been approved by an organization as the authoritative definition of a
|
||||
standard.
|
||||
|
||||
You may add a passage of up to five words as a Front-Cover Text, and a
|
||||
passage of up to 25 words as a Back-Cover Text, to the end of the list
|
||||
of Cover Texts in the Modified Version. Only one passage of
|
||||
Front-Cover Text and one of Back-Cover Text may be added by (or
|
||||
through arrangements made by) any one entity. If the Document already
|
||||
includes a cover text for the same cover, previously added by you or
|
||||
by arrangement made by the same entity you are acting on behalf of,
|
||||
you may not add another; but you may replace the old one, on explicit
|
||||
permission from the previous publisher that added the old one.
|
||||
|
||||
The author(s) and publisher(s) of the Document do not by this License
|
||||
give permission to use their names for publicity for or to assert or
|
||||
imply endorsement of any Modified Version.
|
||||
|
||||
|
||||
5. COMBINING DOCUMENTS
|
||||
|
||||
You may combine the Document with other documents released under this
|
||||
License, under the terms defined in section 4 above for modified
|
||||
versions, provided that you include in the combination all of the
|
||||
Invariant Sections of all of the original documents, unmodified, and
|
||||
list them all as Invariant Sections of your combined work in its
|
||||
license notice, and that you preserve all their Warranty Disclaimers.
|
||||
|
||||
The combined work need only contain one copy of this License, and
|
||||
multiple identical Invariant Sections may be replaced with a single
|
||||
copy. If there are multiple Invariant Sections with the same name but
|
||||
different contents, make the title of each such section unique by
|
||||
adding at the end of it, in parentheses, the name of the original
|
||||
author or publisher of that section if known, or else a unique number.
|
||||
Make the same adjustment to the section titles in the list of
|
||||
Invariant Sections in the license notice of the combined work.
|
||||
|
||||
In the combination, you must combine any sections Entitled "History"
|
||||
in the various original documents, forming one section Entitled
|
||||
"History"; likewise combine any sections Entitled "Acknowledgements",
|
||||
and any sections Entitled "Dedications". You must delete all sections
|
||||
Entitled "Endorsements".
|
||||
|
||||
|
||||
6. COLLECTIONS OF DOCUMENTS
|
||||
|
||||
You may make a collection consisting of the Document and other
|
||||
documents released under this License, and replace the individual
|
||||
copies of this License in the various documents with a single copy
|
||||
that is included in the collection, provided that you follow the rules
|
||||
of this License for verbatim copying of each of the documents in all
|
||||
other respects.
|
||||
|
||||
You may extract a single document from such a collection, and
|
||||
distribute it individually under this License, provided you insert a
|
||||
copy of this License into the extracted document, and follow this
|
||||
License in all other respects regarding verbatim copying of that
|
||||
document.
|
||||
|
||||
|
||||
7. AGGREGATION WITH INDEPENDENT WORKS
|
||||
|
||||
A compilation of the Document or its derivatives with other separate
|
||||
and independent documents or works, in or on a volume of a storage or
|
||||
distribution medium, is called an "aggregate" if the copyright
|
||||
resulting from the compilation is not used to limit the legal rights
|
||||
of the compilation's users beyond what the individual works permit.
|
||||
When the Document is included in an aggregate, this License does not
|
||||
apply to the other works in the aggregate which are not themselves
|
||||
derivative works of the Document.
|
||||
|
||||
If the Cover Text requirement of section 3 is applicable to these
|
||||
copies of the Document, then if the Document is less than one half of
|
||||
the entire aggregate, the Document's Cover Texts may be placed on
|
||||
covers that bracket the Document within the aggregate, or the
|
||||
electronic equivalent of covers if the Document is in electronic form.
|
||||
Otherwise they must appear on printed covers that bracket the whole
|
||||
aggregate.
|
||||
|
||||
|
||||
8. TRANSLATION
|
||||
|
||||
Translation is considered a kind of modification, so you may
|
||||
distribute translations of the Document under the terms of section 4.
|
||||
Replacing Invariant Sections with translations requires special
|
||||
permission from their copyright holders, but you may include
|
||||
translations of some or all Invariant Sections in addition to the
|
||||
original versions of these Invariant Sections. You may include a
|
||||
translation of this License, and all the license notices in the
|
||||
Document, and any Warranty Disclaimers, provided that you also include
|
||||
the original English version of this License and the original versions
|
||||
of those notices and disclaimers. In case of a disagreement between
|
||||
the translation and the original version of this License or a notice
|
||||
or disclaimer, the original version will prevail.
|
||||
|
||||
If a section in the Document is Entitled "Acknowledgements",
|
||||
"Dedications", or "History", the requirement (section 4) to Preserve
|
||||
its Title (section 1) will typically require changing the actual
|
||||
title.
|
||||
|
||||
|
||||
9. TERMINATION
|
||||
|
||||
You may not copy, modify, sublicense, or distribute the Document
|
||||
except as expressly provided under this License. Any attempt
|
||||
otherwise to copy, modify, sublicense, or distribute it is void, and
|
||||
will automatically terminate your rights under this License.
|
||||
|
||||
However, if you cease all violation of this License, then your license
|
||||
from a particular copyright holder is reinstated (a) provisionally,
|
||||
unless and until the copyright holder explicitly and finally
|
||||
terminates your license, and (b) permanently, if the copyright holder
|
||||
fails to notify you of the violation by some reasonable means prior to
|
||||
60 days after the cessation.
|
||||
|
||||
Moreover, your license from a particular copyright holder is
|
||||
reinstated permanently if the copyright holder notifies you of the
|
||||
violation by some reasonable means, this is the first time you have
|
||||
received notice of violation of this License (for any work) from that
|
||||
copyright holder, and you cure the violation prior to 30 days after
|
||||
your receipt of the notice.
|
||||
|
||||
Termination of your rights under this section does not terminate the
|
||||
licenses of parties who have received copies or rights from you under
|
||||
this License. If your rights have been terminated and not permanently
|
||||
reinstated, receipt of a copy of some or all of the same material does
|
||||
not give you any rights to use it.
|
||||
|
||||
|
||||
10. FUTURE REVISIONS OF THIS LICENSE
|
||||
|
||||
The Free Software Foundation may publish new, revised versions of the
|
||||
GNU Free Documentation License from time to time. Such new versions
|
||||
will be similar in spirit to the present version, but may differ in
|
||||
detail to address new problems or concerns. See
|
||||
http://www.gnu.org/copyleft/.
|
||||
|
||||
Each version of the License is given a distinguishing version number.
|
||||
If the Document specifies that a particular numbered version of this
|
||||
License "or any later version" applies to it, you have the option of
|
||||
following the terms and conditions either of that specified version or
|
||||
of any later version that has been published (not as a draft) by the
|
||||
Free Software Foundation. If the Document does not specify a version
|
||||
number of this License, you may choose any version ever published (not
|
||||
as a draft) by the Free Software Foundation. If the Document
|
||||
specifies that a proxy can decide which future versions of this
|
||||
License can be used, that proxy's public statement of acceptance of a
|
||||
version permanently authorizes you to choose that version for the
|
||||
Document.
|
||||
|
||||
11. RELICENSING
|
||||
|
||||
"Massive Multiauthor Collaboration Site" (or "MMC Site") means any
|
||||
World Wide Web server that publishes copyrightable works and also
|
||||
provides prominent facilities for anybody to edit those works. A
|
||||
public wiki that anybody can edit is an example of such a server. A
|
||||
"Massive Multiauthor Collaboration" (or "MMC") contained in the site
|
||||
means any set of copyrightable works thus published on the MMC site.
|
||||
|
||||
"CC-BY-SA" means the Creative Commons Attribution-Share Alike 3.0
|
||||
license published by Creative Commons Corporation, a not-for-profit
|
||||
corporation with a principal place of business in San Francisco,
|
||||
California, as well as future copyleft versions of that license
|
||||
published by that same organization.
|
||||
|
||||
"Incorporate" means to publish or republish a Document, in whole or in
|
||||
part, as part of another Document.
|
||||
|
||||
An MMC is "eligible for relicensing" if it is licensed under this
|
||||
License, and if all works that were first published under this License
|
||||
somewhere other than this MMC, and subsequently incorporated in whole or
|
||||
in part into the MMC, (1) had no cover texts or invariant sections, and
|
||||
(2) were thus incorporated prior to November 1, 2008.
|
||||
|
||||
The operator of an MMC Site may republish an MMC contained in the site
|
||||
under CC-BY-SA on the same site at any time before August 1, 2009,
|
||||
provided the MMC is eligible for relicensing.
|
||||
|
||||
|
||||
ADDENDUM: How to use this License for your documents
|
||||
|
||||
To use this License in a document you have written, include a copy of
|
||||
the License in the document and put the following copyright and
|
||||
license notices just after the title page:
|
||||
|
||||
Copyright (c) YEAR YOUR NAME.
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
If you have Invariant Sections, Front-Cover Texts and Back-Cover Texts,
|
||||
replace the "with...Texts." line with this:
|
||||
|
||||
with the Invariant Sections being LIST THEIR TITLES, with the
|
||||
Front-Cover Texts being LIST, and with the Back-Cover Texts being LIST.
|
||||
|
||||
If you have Invariant Sections without Cover Texts, or some other
|
||||
combination of the three, merge those two alternatives to suit the
|
||||
situation.
|
||||
|
||||
If your document contains nontrivial examples of program code, we
|
||||
recommend releasing these examples in parallel under your choice of
|
||||
free software license, such as the GNU General Public License,
|
||||
to permit their use in free software.
|
177
docs/Makefile
Normal file
@ -0,0 +1,177 @@
|
||||
# Makefile for Sphinx documentation
|
||||
#
|
||||
|
||||
# You can set these variables from the command line.
|
||||
SPHINXOPTS =
|
||||
SPHINXBUILD = sphinx-build
|
||||
PAPER =
|
||||
BUILDDIR = build
|
||||
|
||||
# User-friendly check for sphinx-build
|
||||
ifeq ($(shell which $(SPHINXBUILD) >/dev/null 2>&1; echo $$?), 1)
|
||||
$(error The '$(SPHINXBUILD)' command was not found. Make sure you have Sphinx installed, then set the SPHINXBUILD environment variable to point to the full path of the '$(SPHINXBUILD)' executable. Alternatively you can add the directory with the executable to your PATH. If you don't have Sphinx installed, grab it from http://sphinx-doc.org/)
|
||||
endif
|
||||
|
||||
# Internal variables.
|
||||
PAPEROPT_a4 = -D latex_paper_size=a4
|
||||
PAPEROPT_letter = -D latex_paper_size=letter
|
||||
ALLSPHINXOPTS = -d $(BUILDDIR)/doctrees $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
||||
# the i18n builder cannot share the environment and doctrees with the others
|
||||
I18NSPHINXOPTS = $(PAPEROPT_$(PAPER)) $(SPHINXOPTS) source
|
||||
|
||||
.PHONY: help clean html dirhtml singlehtml pickle json htmlhelp qthelp devhelp epub latex latexpdf text man changes linkcheck doctest gettext
|
||||
|
||||
help:
|
||||
@echo "Please use \`make <target>' where <target> is one of"
|
||||
@echo " html to make standalone HTML files"
|
||||
@echo " dirhtml to make HTML files named index.html in directories"
|
||||
@echo " singlehtml to make a single large HTML file"
|
||||
@echo " pickle to make pickle files"
|
||||
@echo " json to make JSON files"
|
||||
@echo " htmlhelp to make HTML files and a HTML help project"
|
||||
@echo " qthelp to make HTML files and a qthelp project"
|
||||
@echo " devhelp to make HTML files and a Devhelp project"
|
||||
@echo " epub to make an epub"
|
||||
@echo " latex to make LaTeX files, you can set PAPER=a4 or PAPER=letter"
|
||||
@echo " latexpdf to make LaTeX files and run them through pdflatex"
|
||||
@echo " latexpdfja to make LaTeX files and run them through platex/dvipdfmx"
|
||||
@echo " text to make text files"
|
||||
@echo " man to make manual pages"
|
||||
@echo " texinfo to make Texinfo files"
|
||||
@echo " info to make Texinfo files and run them through makeinfo"
|
||||
@echo " gettext to make PO message catalogs"
|
||||
@echo " changes to make an overview of all changed/added/deprecated items"
|
||||
@echo " xml to make Docutils-native XML files"
|
||||
@echo " pseudoxml to make pseudoxml-XML files for display purposes"
|
||||
@echo " linkcheck to check all external links for integrity"
|
||||
@echo " doctest to run all doctests embedded in the documentation (if enabled)"
|
||||
|
||||
clean:
|
||||
rm -rf $(BUILDDIR)/*
|
||||
|
||||
html:
|
||||
$(SPHINXBUILD) -b html $(ALLSPHINXOPTS) $(BUILDDIR)/html
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/html."
|
||||
|
||||
dirhtml:
|
||||
$(SPHINXBUILD) -b dirhtml $(ALLSPHINXOPTS) $(BUILDDIR)/dirhtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML pages are in $(BUILDDIR)/dirhtml."
|
||||
|
||||
singlehtml:
|
||||
$(SPHINXBUILD) -b singlehtml $(ALLSPHINXOPTS) $(BUILDDIR)/singlehtml
|
||||
@echo
|
||||
@echo "Build finished. The HTML page is in $(BUILDDIR)/singlehtml."
|
||||
|
||||
pickle:
|
||||
$(SPHINXBUILD) -b pickle $(ALLSPHINXOPTS) $(BUILDDIR)/pickle
|
||||
@echo
|
||||
@echo "Build finished; now you can process the pickle files."
|
||||
|
||||
json:
|
||||
$(SPHINXBUILD) -b json $(ALLSPHINXOPTS) $(BUILDDIR)/json
|
||||
@echo
|
||||
@echo "Build finished; now you can process the JSON files."
|
||||
|
||||
htmlhelp:
|
||||
$(SPHINXBUILD) -b htmlhelp $(ALLSPHINXOPTS) $(BUILDDIR)/htmlhelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run HTML Help Workshop with the" \
|
||||
".hhp project file in $(BUILDDIR)/htmlhelp."
|
||||
|
||||
qthelp:
|
||||
$(SPHINXBUILD) -b qthelp $(ALLSPHINXOPTS) $(BUILDDIR)/qthelp
|
||||
@echo
|
||||
@echo "Build finished; now you can run "qcollectiongenerator" with the" \
|
||||
".qhcp project file in $(BUILDDIR)/qthelp, like this:"
|
||||
@echo "# qcollectiongenerator $(BUILDDIR)/qthelp/chill-doc.qhcp"
|
||||
@echo "To view the help file:"
|
||||
@echo "# assistant -collectionFile $(BUILDDIR)/qthelp/chill-doc.qhc"
|
||||
|
||||
devhelp:
|
||||
$(SPHINXBUILD) -b devhelp $(ALLSPHINXOPTS) $(BUILDDIR)/devhelp
|
||||
@echo
|
||||
@echo "Build finished."
|
||||
@echo "To view the help file:"
|
||||
@echo "# mkdir -p $$HOME/.local/share/devhelp/chill-doc"
|
||||
@echo "# ln -s $(BUILDDIR)/devhelp $$HOME/.local/share/devhelp/chill-doc"
|
||||
@echo "# devhelp"
|
||||
|
||||
epub:
|
||||
$(SPHINXBUILD) -b epub $(ALLSPHINXOPTS) $(BUILDDIR)/epub
|
||||
@echo
|
||||
@echo "Build finished. The epub file is in $(BUILDDIR)/epub."
|
||||
|
||||
latex:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo
|
||||
@echo "Build finished; the LaTeX files are in $(BUILDDIR)/latex."
|
||||
@echo "Run \`make' in that directory to run these through (pdf)latex" \
|
||||
"(use \`make latexpdf' here to do that automatically)."
|
||||
|
||||
latexpdf:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through pdflatex..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
latexpdfja:
|
||||
$(SPHINXBUILD) -b latex $(ALLSPHINXOPTS) $(BUILDDIR)/latex
|
||||
@echo "Running LaTeX files through platex and dvipdfmx..."
|
||||
$(MAKE) -C $(BUILDDIR)/latex all-pdf-ja
|
||||
@echo "pdflatex finished; the PDF files are in $(BUILDDIR)/latex."
|
||||
|
||||
text:
|
||||
$(SPHINXBUILD) -b text $(ALLSPHINXOPTS) $(BUILDDIR)/text
|
||||
@echo
|
||||
@echo "Build finished. The text files are in $(BUILDDIR)/text."
|
||||
|
||||
man:
|
||||
$(SPHINXBUILD) -b man $(ALLSPHINXOPTS) $(BUILDDIR)/man
|
||||
@echo
|
||||
@echo "Build finished. The manual pages are in $(BUILDDIR)/man."
|
||||
|
||||
texinfo:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo
|
||||
@echo "Build finished. The Texinfo files are in $(BUILDDIR)/texinfo."
|
||||
@echo "Run \`make' in that directory to run these through makeinfo" \
|
||||
"(use \`make info' here to do that automatically)."
|
||||
|
||||
info:
|
||||
$(SPHINXBUILD) -b texinfo $(ALLSPHINXOPTS) $(BUILDDIR)/texinfo
|
||||
@echo "Running Texinfo files through makeinfo..."
|
||||
make -C $(BUILDDIR)/texinfo info
|
||||
@echo "makeinfo finished; the Info files are in $(BUILDDIR)/texinfo."
|
||||
|
||||
gettext:
|
||||
$(SPHINXBUILD) -b gettext $(I18NSPHINXOPTS) $(BUILDDIR)/locale
|
||||
@echo
|
||||
@echo "Build finished. The message catalogs are in $(BUILDDIR)/locale."
|
||||
|
||||
changes:
|
||||
$(SPHINXBUILD) -b changes $(ALLSPHINXOPTS) $(BUILDDIR)/changes
|
||||
@echo
|
||||
@echo "The overview file is in $(BUILDDIR)/changes."
|
||||
|
||||
linkcheck:
|
||||
$(SPHINXBUILD) -b linkcheck $(ALLSPHINXOPTS) $(BUILDDIR)/linkcheck
|
||||
@echo
|
||||
@echo "Link check complete; look for any errors in the above output " \
|
||||
"or in $(BUILDDIR)/linkcheck/output.txt."
|
||||
|
||||
doctest:
|
||||
$(SPHINXBUILD) -b doctest $(ALLSPHINXOPTS) $(BUILDDIR)/doctest
|
||||
@echo "Testing of doctests in the sources finished, look at the " \
|
||||
"results in $(BUILDDIR)/doctest/output.txt."
|
||||
|
||||
xml:
|
||||
$(SPHINXBUILD) -b xml $(ALLSPHINXOPTS) $(BUILDDIR)/xml
|
||||
@echo
|
||||
@echo "Build finished. The XML files are in $(BUILDDIR)/xml."
|
||||
|
||||
pseudoxml:
|
||||
$(SPHINXBUILD) -b pseudoxml $(ALLSPHINXOPTS) $(BUILDDIR)/pseudoxml
|
||||
@echo
|
||||
@echo "Build finished. The pseudo-XML files are in $(BUILDDIR)/pseudoxml."
|
26
docs/README.md
Normal file
@ -0,0 +1,26 @@
|
||||
Chill documentation
|
||||
====================
|
||||
|
||||
Documentation of the Chill software.
|
||||
|
||||
The compiled documentation may be read at http://docs.chill.social
|
||||
|
||||
Compilation into HTML
|
||||
=====================
|
||||
|
||||
To compile this documentation :
|
||||
|
||||
1. Install [sphinx-doc](http://sphinx-doc.org) (eg. pip install sphinx & pip install sphinx_rtd_theme)
|
||||
2. Install submodules : $ git submodule update --init;
|
||||
3. run `make html` from the root directory
|
||||
4. The base file is located on build/html/index.html
|
||||
|
||||
Contribute
|
||||
===========
|
||||
|
||||
Issue tracker : https://git.framasoft.org/groups/Chill-project/issues
|
||||
|
||||
Licence
|
||||
=======
|
||||
|
||||
This documentation is available under the [GNU Free Documentation Licence](http://www.gnu.org/licenses/fdl-1.3.en.html).
|
0
docs/build/git.txt
vendored
Normal file
13
docs/requirements.txt
Normal file
@ -0,0 +1,13 @@
|
||||
alabaster==0.7.10
|
||||
Babel==2.4.0
|
||||
docutils==0.13.1
|
||||
imagesize==0.7.1
|
||||
Jinja2==2.10.1
|
||||
MarkupSafe==1.0
|
||||
Pygments==2.2.0
|
||||
pytz==2017.2
|
||||
requests==2.20.0
|
||||
six==1.10.0
|
||||
snowballstemmer==1.2.1
|
||||
Sphinx==1.3.6
|
||||
git+https://github.com/fabpot/sphinx-php.git@7312eccce9465640752e51373a480da700e02345#egg_name=sphinx-php
|
BIN
docs/source/_static/access_control_model.png
Normal file
After Width: | Height: | Size: 17 KiB |
BIN
docs/source/_static/bundles/docStore/doc_store_classes.png
Normal file
After Width: | Height: | Size: 30 KiB |
46
docs/source/_static/bundles/docStore/doc_store_classes.puml
Normal file
@ -0,0 +1,46 @@
|
||||
# diagramme de classe du module "docStore"
|
||||
|
||||
@startuml
|
||||
|
||||
title Diagramme de classe du module "docStore"
|
||||
|
||||
|
||||
package "PersonBundle" {
|
||||
class Person
|
||||
class Center
|
||||
class PersonDocument
|
||||
}
|
||||
|
||||
package "DocStoreBundle" {
|
||||
Document "many" --- "1" DocumentCategory
|
||||
}
|
||||
|
||||
Document <|-- "herite" PersonDocument
|
||||
|
||||
class "Document" {
|
||||
- int id
|
||||
- varchar_150 title
|
||||
- text description
|
||||
- ArrayCollection_DocumentCategory categories
|
||||
- varchar_150 content #link to openstack
|
||||
- Center center
|
||||
- Cercle cercle
|
||||
- User user
|
||||
- DateTime date # Creation date
|
||||
}
|
||||
|
||||
|
||||
class "DocumentCategory" {
|
||||
.. Primary Key ..
|
||||
- varchar_150 bundle_id
|
||||
- int internal_bundle_id
|
||||
==
|
||||
- json_array name
|
||||
- ArrayCollection_Document documents
|
||||
}
|
||||
|
||||
class "PersonDocument" {
|
||||
- Person person
|
||||
}
|
||||
|
||||
@enduml
|
BIN
docs/source/_static/bundles/group/group_classes_uml.png
Normal file
After Width: | Height: | Size: 50 KiB |
49
docs/source/_static/bundles/group/group_classes_uml.pu
Normal file
@ -0,0 +1,49 @@
|
||||
# diagramme de classe du module "groupe"
|
||||
|
||||
@startuml
|
||||
|
||||
title Diagramme de classe du module "groupe"
|
||||
|
||||
package "PersonBundle" {
|
||||
class Person
|
||||
class Center
|
||||
}
|
||||
|
||||
package "GroupBundle" {
|
||||
Person "1" <-- Membership
|
||||
Membership "0..*" <--> "Group"
|
||||
Type "1" --> "1..*" Role
|
||||
Membership -right-> "1" Role
|
||||
Group -right-> "1" Type
|
||||
Group -left-> "1" Center
|
||||
}
|
||||
|
||||
class Membership {
|
||||
- role
|
||||
- person
|
||||
- group
|
||||
}
|
||||
note left: <b>Membership</b> relie les groupes aux\npersonnes. Chaque membership a un\n <b>role</b>, le rôle est à choisir\nparmi ceux possibles pour le <b>type</b> de <b>groupe</b>
|
||||
|
||||
class Group {
|
||||
- type
|
||||
- memberships
|
||||
- name
|
||||
- center
|
||||
}
|
||||
note left: Un groupe a un type qui est défini à sa création.
|
||||
|
||||
class Type {
|
||||
- roles
|
||||
}
|
||||
note right: Les types de groupe qu'il est possible de créer \nsont définis dans l'interface d'administration.\nExemple de type: "famille", "groupe de parole", "stage", ...
|
||||
|
||||
class Role {
|
||||
- name
|
||||
}
|
||||
note right: Pour chaque <b>Type</b> on définit des rôles\npossibles pour ce type de groupe. Par exemple, pour le\ntype "famille" on peut avoir les rôles <i>parents</i> et <i>enfants</i>.
|
||||
|
||||
|
||||
|
||||
|
||||
@enduml
|
123
docs/source/_static/code/exports/BirthdateFilter.php
Normal file
@ -0,0 +1,123 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\PersonBundle\Export\Filter;
|
||||
|
||||
use Chill\MainBundle\Export\FilterInterface;
|
||||
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||||
use Symfony\Component\Validator\Context\ExecutionContextInterface;
|
||||
use Symfony\Component\Validator\Constraints;
|
||||
use Symfony\Component\Form\FormEvent;
|
||||
use Symfony\Component\Form\FormEvents;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Chill\MainBundle\Form\Type\Export\FilterType;
|
||||
use Symfony\Component\Form\FormError;
|
||||
use Chill\MainBundle\Export\ExportElementValidatedInterface;
|
||||
|
||||
class BirthdateFilter implements FilterInterface, ExportElementValidatedInterface
|
||||
{
|
||||
// add specific role for this filter
|
||||
public function addRole()
|
||||
{
|
||||
// we do not need any new role for this filter, so we return null
|
||||
return null;
|
||||
}
|
||||
|
||||
// we give information on which type of export this filter applies
|
||||
public function applyOn()
|
||||
{
|
||||
return 'person';
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return 'Filter by person\'s birthdate';
|
||||
}
|
||||
|
||||
// we build a form to collect some parameters from the users
|
||||
public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder)
|
||||
{
|
||||
$builder->add('date_from', DateType::class, array(
|
||||
'label' => "Born after this date",
|
||||
'data' => new \DateTime(),
|
||||
'attr' => array('class' => 'datepicker'),
|
||||
'widget'=> 'single_text',
|
||||
'format' => 'dd-MM-yyyy',
|
||||
));
|
||||
|
||||
$builder->add('date_to', DateType::class, array(
|
||||
'label' => "Born before this date",
|
||||
'data' => new \DateTime(),
|
||||
'attr' => array('class' => 'datepicker'),
|
||||
'widget'=> 'single_text',
|
||||
'format' => 'dd-MM-yyyy',
|
||||
));
|
||||
|
||||
}
|
||||
|
||||
// the form created above must be validated. The process of validation
|
||||
// is executed here. This function is added by the interface
|
||||
// `ExportElementValidatedInterface`, and can be ignore if there is
|
||||
// no need for a validation
|
||||
public function validateForm($data, ExecutionContextInterface $context)
|
||||
{
|
||||
$date_from = $data['date_from'];
|
||||
$date_to = $data['date_to'];
|
||||
|
||||
if ($date_from === null) {
|
||||
$context->buildViolation('The "date from" should not be empty')
|
||||
//->atPath('date_from')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if ($date_to === null) {
|
||||
$context->buildViolation('The "date to" should not be empty')
|
||||
//->atPath('date_to')
|
||||
->addViolation();
|
||||
}
|
||||
|
||||
if (
|
||||
($date_from !== null && $date_to !== null)
|
||||
&&
|
||||
$date_from >= $date_to
|
||||
) {
|
||||
$context->buildViolation('The date "date to" should be after the '
|
||||
. 'date given in "date from" field')
|
||||
->addViolation();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
// here, we alter the query created by Export
|
||||
public function alterQuery(\Doctrine\ORM\QueryBuilder $qb, $data)
|
||||
{
|
||||
$where = $qb->getDQLPart('where');
|
||||
// we create the clause here
|
||||
$clause = $qb->expr()->between('person.birthdate', ':date_from',
|
||||
':date_to');
|
||||
|
||||
// we have to take care **not to** remove previous clauses...
|
||||
if ($where instanceof Expr\Andx) {
|
||||
$where->add($clause);
|
||||
} else {
|
||||
$where = $qb->expr()->andX($clause);
|
||||
}
|
||||
|
||||
$qb->add('where', $where);
|
||||
// we add parameters from $data. $data contains the parameters from the form
|
||||
$qb->setParameter('date_from', $data['date_from']);
|
||||
$qb->setParameter('date_to', $data['date_to']);
|
||||
}
|
||||
|
||||
// here, we create a simple string which will describe the action of
|
||||
// the filter in the Response
|
||||
public function describeAction($data, $format = 'string')
|
||||
{
|
||||
return array('Filtered by person\'s birtdate: '
|
||||
. 'between %date_from% and %date_to%', array(
|
||||
'%date_from%' => $data['date_from']->format('d-m-Y'),
|
||||
'%date_to%' => $data['date_to']->format('d-m-Y')
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
}
|
118
docs/source/_static/code/exports/CountPerson.php
Normal file
@ -0,0 +1,118 @@
|
||||
<?php
|
||||
|
||||
|
||||
namespace Chill\PersonBundle\Export\Export;
|
||||
|
||||
use Chill\MainBundle\Export\ExportInterface;
|
||||
use Doctrine\ORM\QueryBuilder;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Doctrine\ORM\Query;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Chill\PersonBundle\Export\Declarations;
|
||||
use Chill\MainBundle\Export\FormatterInterface;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
*/
|
||||
class CountPerson implements ExportInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @var EntityManagerInterface
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
public function __construct(
|
||||
EntityManagerInterface $em
|
||||
)
|
||||
{
|
||||
$this->entityManager = $em;
|
||||
}
|
||||
|
||||
public function getType()
|
||||
{
|
||||
return Declarations::PERSON_TYPE;
|
||||
}
|
||||
|
||||
public function getDescription()
|
||||
{
|
||||
return "Count peoples by various parameters.";
|
||||
}
|
||||
|
||||
public function getTitle()
|
||||
{
|
||||
return "Count peoples";
|
||||
}
|
||||
|
||||
public function requiredRole()
|
||||
{
|
||||
return new Role(PersonVoter::STATS);
|
||||
}
|
||||
|
||||
public function initiateQuery(array $requiredModifiers, array $acl, array $data = array())
|
||||
{
|
||||
// we gather all center the user choose.
|
||||
$centers = array_map(function($el) { return $el['center']; }, $acl);
|
||||
|
||||
$qb = $this->entityManager->createQueryBuilder();
|
||||
|
||||
$qb->select('COUNT(person.id) AS export_result')
|
||||
->from('ChillPersonBundle:Person', 'person')
|
||||
->join('person.center', 'center')
|
||||
->andWhere('center IN (:authorized_centers)')
|
||||
->setParameter('authorized_centers', $centers);
|
||||
;
|
||||
|
||||
|
||||
return $qb;
|
||||
}
|
||||
|
||||
public function getResult($qb, $data)
|
||||
{
|
||||
return $qb->getQuery()->getResult(Query::HYDRATE_SCALAR);
|
||||
}
|
||||
|
||||
public function getQueryKeys($data)
|
||||
{
|
||||
// this array match the result keys in the query. We have only
|
||||
// one column.
|
||||
return array('export_result');
|
||||
}
|
||||
|
||||
public function getLabels($key, array $values, $data)
|
||||
{
|
||||
|
||||
// the Closure which will be executed by the formatter.
|
||||
return function($value) {
|
||||
switch($value) {
|
||||
case '_header':
|
||||
// we have to process specifically the '_header' string,
|
||||
// which will be used by the formatter to show a column title
|
||||
return $this->getTitle();
|
||||
default:
|
||||
// for all value, we do not process them and return them
|
||||
// immediatly
|
||||
return $value;
|
||||
};
|
||||
}
|
||||
|
||||
public function getAllowedFormattersTypes()
|
||||
{
|
||||
return array(FormatterInterface::TYPE_TABULAR);
|
||||
}
|
||||
|
||||
public function buildForm(FormBuilderInterface $builder) {
|
||||
// this export does not add any form
|
||||
}
|
||||
|
||||
public function supportsModifiers()
|
||||
{
|
||||
// explain the export manager which formatters and filters are allowed
|
||||
return array(Declarations::PERSON_TYPE, Declarations::PERSON_IMPLIED_IN);
|
||||
}
|
||||
|
||||
}
|
35
docs/source/_static/code/installation/docker-compose.yml
Normal file
@ -0,0 +1,35 @@
|
||||
version: '2'
|
||||
services:
|
||||
fpm:
|
||||
image: dev-activity-person-report
|
||||
links:
|
||||
- db
|
||||
- redis
|
||||
- logstash:gelf
|
||||
environment:
|
||||
- ADMIN_PASSWORD=admin
|
||||
# add a link to custom.yml if needed
|
||||
# volumes:
|
||||
# - /tmp/custom.yml:/var/www/chill/app/config/custom.yml
|
||||
redis:
|
||||
image: redis
|
||||
db:
|
||||
image: chill/database
|
||||
logstash:
|
||||
image: logstash
|
||||
command: logstash -e 'input { gelf { } } output { stdout{ } }'
|
||||
expose:
|
||||
- "12201/udp"
|
||||
volumes:
|
||||
- /var/log/logstash
|
||||
nginx:
|
||||
image: nginx
|
||||
links:
|
||||
- fpm
|
||||
volumes:
|
||||
- ./nginx.conf:/etc/nginx/nginx.conf
|
||||
volumes_from:
|
||||
- fpm:ro
|
||||
ports:
|
||||
- 8080:80
|
||||
|
71
docs/source/_static/code/installation/nginx.conf
Normal file
@ -0,0 +1,71 @@
|
||||
user nginx;
|
||||
worker_processes 1;
|
||||
|
||||
error_log /var/log/nginx/error.log warn;
|
||||
pid /var/run/nginx.pid;
|
||||
|
||||
|
||||
events {
|
||||
worker_connections 1024;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
http {
|
||||
include /etc/nginx/mime.types;
|
||||
default_type application/octet-stream;
|
||||
|
||||
log_format main '$remote_addr - $remote_user [$time_local] "$request" '
|
||||
'$status $body_bytes_sent "$http_referer" '
|
||||
'"$http_user_agent" "$http_x_forwarded_for"';
|
||||
|
||||
access_log /var/log/nginx/access.log main;
|
||||
error_log /var/log/nginx/error.log;
|
||||
|
||||
sendfile on;
|
||||
#tcp_nopush on;
|
||||
|
||||
keepalive_timeout 65;
|
||||
|
||||
gzip off;
|
||||
|
||||
#include /etc/nginx/conf.d/*.conf;
|
||||
|
||||
upstream phpfcgi {
|
||||
server fpm:9000;
|
||||
# server unix:/var/run/php5-fpm.sock; #for PHP-FPM running on UNIX socket
|
||||
}
|
||||
|
||||
server {
|
||||
listen 80;
|
||||
|
||||
#server_name symfony2;
|
||||
root /var/www/chill/web;
|
||||
|
||||
error_log /var/log/nginx/symfony2.error.log;
|
||||
access_log /var/log/nginx/symfony2.access.log;
|
||||
|
||||
# strip app.php/ prefix if it is present
|
||||
rewrite ^/app\.php/?(.*)$ /$1 permanent;
|
||||
|
||||
location / {
|
||||
index app.php;
|
||||
try_files $uri @rewriteapp;
|
||||
}
|
||||
|
||||
location @rewriteapp {
|
||||
rewrite ^(.*)$ /app.php/$1 last;
|
||||
}
|
||||
|
||||
# pass the PHP scripts to FastCGI server from upstream phpfcgi
|
||||
location ~ ^/(app|app_dev|config)\.php(/|$) {
|
||||
fastcgi_pass phpfcgi;
|
||||
fastcgi_split_path_info ^(.+\.php)(/.*)$;
|
||||
include fastcgi_params;
|
||||
fastcgi_param SCRIPT_FILENAME $document_root$fastcgi_script_name;
|
||||
fastcgi_param HTTPS off;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
BIN
docs/source/_static/puml/exports/form_steps.png
Normal file
After Width: | Height: | Size: 70 KiB |
82
docs/source/_static/puml/exports/form_steps.puml
Normal file
@ -0,0 +1,82 @@
|
||||
@startuml
|
||||
|
||||
actor User
|
||||
participant Controller
|
||||
participant ExportFormType as eft
|
||||
participant ExportManager as em
|
||||
participant SelectedExport as se
|
||||
participant AggregatorFormType as aft
|
||||
collections aggregators as a
|
||||
participant FilterFormType as fft
|
||||
collections filters as f
|
||||
|
||||
|
||||
User -> Controller: request "/exports/new/<id of the export>?step=export"
|
||||
|
||||
activate Controller
|
||||
Controller -> eft: build the form (AbstractType::buildForm)
|
||||
|
||||
activate eft
|
||||
eft -> em: get the export
|
||||
|
||||
activate em
|
||||
em -> eft: return the SelectedExport
|
||||
deactivate em
|
||||
|
||||
eft -> se: get the Export Type
|
||||
|
||||
activate se
|
||||
se -> eft: return the export Type (a string)
|
||||
deactivate se
|
||||
|
||||
eft -> aft: build the subform 'aggregators'
|
||||
activate aft
|
||||
|
||||
aft -> em: get aggregators for this export type
|
||||
activate em
|
||||
em -> aft: return a collection of aggregators
|
||||
deactivate em
|
||||
|
||||
loop for each aggregator
|
||||
aft -> a: build eventual subform for the aggregator
|
||||
activate a
|
||||
a -> a: append enventually his form
|
||||
a -> aft
|
||||
deactivate a
|
||||
end
|
||||
|
||||
aft -> eft
|
||||
deactivate aft
|
||||
|
||||
eft -> fft: build the subform 'filters'
|
||||
activate fft
|
||||
|
||||
fft -> em: get filters for this export type
|
||||
activate em
|
||||
em -> fft: return a collection for filters
|
||||
deactivate em
|
||||
|
||||
loop for each filter
|
||||
fft -> f: build eventual subform for the filter
|
||||
activate f
|
||||
f -> f: append eventually his form
|
||||
f -> fft
|
||||
deactivate f
|
||||
end
|
||||
|
||||
fft -> eft
|
||||
deactivate fft
|
||||
|
||||
eft -> se: build eventual subform for the export itsefl
|
||||
activate se
|
||||
se -> se: append eventually his form
|
||||
se -> eft
|
||||
deactivate se
|
||||
|
||||
se -> Controller: return a well-build form
|
||||
deactivate se
|
||||
|
||||
Controller -> User: render the page with the form
|
||||
deactivate Controller
|
||||
@enduml
|
||||
|
BIN
docs/source/_static/puml/exports/processing_export.png
Normal file
After Width: | Height: | Size: 178 KiB |
164
docs/source/_static/puml/exports/processing_export.puml
Normal file
@ -0,0 +1,164 @@
|
||||
@startuml
|
||||
|
||||
participant Controller
|
||||
participant ExportManager as em
|
||||
participant SelectedExport as se
|
||||
participant Formatter as f
|
||||
collections aggregators as aa
|
||||
collections filters as ff
|
||||
|
||||
activate Controller
|
||||
Controller -> em: ExportManager::generate(string 'export_alias', Centers[], $data, $formatterdata)
|
||||
activate em
|
||||
note left
|
||||
$data contains the data
|
||||
from the export form
|
||||
(export form + aggregators form +
|
||||
filters forms)
|
||||
end note
|
||||
|
||||
|
||||
em -> se: Export::initiateQuery($modifiers, $acl, $data)
|
||||
activate se
|
||||
note left
|
||||
$modifiers contains the selected modifiers
|
||||
and their data. Usually you can ignore this.
|
||||
$acl contains the list of selected centers. The
|
||||
export must check that the user has the right
|
||||
to compute the export for this center
|
||||
$data the data from the export form (if the export
|
||||
build a form with `buildForm` function
|
||||
end note
|
||||
|
||||
create Query as q
|
||||
se -> q: the export will create a query
|
||||
se -> em: return the query
|
||||
deactivate se
|
||||
|
||||
alt The query is a "native sql query"
|
||||
|
||||
note over em, se
|
||||
When the export create a native query, there aren't any filters
|
||||
or aggregators which can alter the query.
|
||||
|
||||
We immediatly get the results from the query.
|
||||
end note
|
||||
|
||||
else "The query is a query builder"
|
||||
|
||||
note over em, se
|
||||
As the query is a query builder, filters and formatters
|
||||
will be able to alter the query.
|
||||
end note
|
||||
|
||||
loop for each filter selected by user
|
||||
em -> ff: FilterInterface::alterQuery(query, $data)
|
||||
activate ff
|
||||
note over em, ff
|
||||
The filter will alter query, adding his own clause (i.e. WHERE clause). It is
|
||||
his responsability to avoid removing clauses added by other filters / aggregators.
|
||||
|
||||
The ExportManager will also transmit the $data filled by the user (if the
|
||||
filter has a form) to each filter / aggregator.
|
||||
end note
|
||||
ff -> q: append some clauses
|
||||
deactivate ff
|
||||
end
|
||||
|
||||
loop for each aggregator selected by user
|
||||
note over em, aa
|
||||
As of filter, aggregators will append their
|
||||
own clauses in the query (usually GROUP BY clause).
|
||||
end note
|
||||
em -> aa: AggregatorInterface::alterQuery(query, data)
|
||||
activate aa
|
||||
|
||||
aa -> q: append some clauses
|
||||
deactivate aa
|
||||
end
|
||||
end alt
|
||||
|
||||
note over se
|
||||
The query is now ready. We will fetch the results from databases.
|
||||
|
||||
The Export is responsible for getting the results
|
||||
end note
|
||||
|
||||
em -> se: Export::getResult(query, $data)
|
||||
activate se
|
||||
|
||||
se -> q: getResult()
|
||||
activate q
|
||||
q -> se: return result
|
||||
destroy q
|
||||
|
||||
se -> em: return result
|
||||
deactivate se
|
||||
|
||||
em -> f: FormatterInterface::getResponse()
|
||||
activate f
|
||||
|
||||
note over f, ff
|
||||
The formatter will ask the export, and each aggregators the keys they
|
||||
are responsible for.
|
||||
|
||||
Then, for each of those keys, he will ask to each participant
|
||||
(Export or aggregator) a Closure, which will render the value in
|
||||
results into a human readable string.
|
||||
end note
|
||||
|
||||
f -> se: getQueryKeys
|
||||
activate se
|
||||
se -> f: return string[]
|
||||
|
||||
loop for each keys the export is responsible for
|
||||
f -> se: ExportInterface::getLabel()
|
||||
create "closure for key export" as closuree
|
||||
se -> closuree: create a closure
|
||||
se -> f: return closure
|
||||
end
|
||||
|
||||
loop for each aggregator
|
||||
f -> aa: getQueryKeys()
|
||||
activate aa
|
||||
aa -> f: return string[]
|
||||
deactivate aa
|
||||
|
||||
loop for each keys the aggregator is responsible for
|
||||
f -> aa: getLabel()
|
||||
activate aa
|
||||
create "closure for key aggregators" as closureg
|
||||
aa -> closureg: create a closure
|
||||
aa -> f: return closure
|
||||
deactivate aa
|
||||
end
|
||||
end
|
||||
|
||||
loop over results
|
||||
note over f, closureg
|
||||
Each row in result will be transformed in a human readable format by the closure.
|
||||
|
||||
The human readable string will be appended by the Formatter in his response (a Spreadsheet, CSV file, ...)
|
||||
end note
|
||||
|
||||
f -> closuree: call
|
||||
activate closuree
|
||||
closuree -> f: return a human readable format for this value
|
||||
deactivate closuree
|
||||
|
||||
f -> closureg: call
|
||||
activate closureg
|
||||
closureg -> f: return a human readable format for the value
|
||||
deactivate g
|
||||
|
||||
f -> f: append the result in his response
|
||||
end
|
||||
|
||||
f -> em: return a Response
|
||||
deactivate f
|
||||
|
||||
em -> Controller: return a Response
|
||||
deactivate em
|
||||
deactivate Controller
|
||||
|
||||
@enduml
|
BIN
docs/source/_static/puml/pagination-sequence.png
Normal file
After Width: | Height: | Size: 15 KiB |
20
docs/source/_static/puml/pagination-sequence.puml
Normal file
@ -0,0 +1,20 @@
|
||||
@startuml
|
||||
|
||||
actor "controller, service, ..." as x
|
||||
participant "paginator"
|
||||
participant "Request"
|
||||
|
||||
x -> paginator: getCurrentPage()
|
||||
activate paginator
|
||||
|
||||
paginator -> Request: read the `page` parameter in GET request
|
||||
activate Request
|
||||
Request -> paginator
|
||||
deactivate Request
|
||||
|
||||
paginator -> paginator: construct a page object for current page number
|
||||
paginator -> x: return the `page`
|
||||
deactivate paginator
|
||||
|
||||
@enduml
|
||||
|
After Width: | Height: | Size: 306 KiB |
BIN
docs/source/_static_sources/access_control_model.dia
Normal file
71
docs/source/bundles/activity.rst
Normal file
@ -0,0 +1,71 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _activity-bundle:
|
||||
|
||||
Activity bundle
|
||||
###############
|
||||
|
||||
This bundle provides the ability to record people in the software. This bundle is required by other bundle.
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
Entities provided
|
||||
*****************
|
||||
|
||||
.. todo::
|
||||
|
||||
Describe the entities provided.
|
||||
|
||||
|
||||
Configuration options
|
||||
*********************
|
||||
|
||||
Those options are available under `chill_activity` key.
|
||||
|
||||
Example of configuration:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_activity:
|
||||
form:
|
||||
time_duration:
|
||||
- { label: '12 minutes', seconds: 720 }
|
||||
- { label: '30 minutes', seconds: 1800 }
|
||||
|
||||
form.time_duration *array*
|
||||
The duration which might be suggested when the user create or update an activity. The value must be an array of object, where each object must have a :code:`label` and a :code:`seconds` key. The label provide which is shown to user (the label will be translated, if possible) and the seconds the duration.
|
||||
|
||||
Example: see the example above
|
||||
|
||||
Default value: the values available are 5, 10, 15, 20, 25, 30, 45 minutes, and 1 hour, 1 hour 15, 1 hour 30, 1 hour 45 and 2 hours.
|
||||
|
||||
.. _activity-bundle-macros:
|
||||
|
||||
Macros
|
||||
******
|
||||
|
||||
Activity reason sticker
|
||||
=======================
|
||||
|
||||
Macro file
|
||||
`ChillActivityBundle:ActivityReason:macro.html.twig`
|
||||
Macro envelope
|
||||
:code:`reason(r)`
|
||||
|
||||
:code:`p` is an instance of :class:`Chill\ActivityBundle\Entity\ActivityReason`
|
||||
|
||||
When to use this macro ?
|
||||
When you want to represent an activity reason.
|
||||
Example usage :
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{% import 'ChillActivityBundle:ActivityReason:macro.html.twig' as m %}
|
||||
|
||||
{{ m.reason(r) }}
|
441
docs/source/bundles/custom-fields.rst
Normal file
@ -0,0 +1,441 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _custom-fields-bundle:
|
||||
|
||||
Custom fields bundle
|
||||
====================
|
||||
|
||||
This bundle provides the ability to add custom fields to existing entities.
|
||||
|
||||
Those custom fields contains extra data and will be stored in the DB, along with other data's entities. It may be string, text, date, ... or a link to an existing entities.
|
||||
|
||||
In the database, custom fields are stored in json format.
|
||||
|
||||
.. seealso::
|
||||
|
||||
The full specification discussed `here. <https://redmine.champs-libres.coop/issues/239>`_
|
||||
|
||||
`JSON Type on postgresql documentation <http://www.postgresql.org/docs/9.3/static/datatype-json.html>`_
|
||||
The documentation of json type, which is used to store data in the database.
|
||||
|
||||
.. contents:: Table of contents
|
||||
:depth: 4
|
||||
:local:
|
||||
|
||||
Custom Fields concepts
|
||||
----------------------
|
||||
|
||||
Custom fields are extra data which may be added to entities by user. If a developer implements custom fields on a entity, users will be able to add more fields on this entity.
|
||||
|
||||
Example: the `person bundle` allows to record `firstname`, `lastname`, `date of birth` fields. But users need to store information about the kind of house he has (if he owns his house, if he rents it, ...). Custom fields allows to create those fields.
|
||||
|
||||
Automatically, those fields are added at the person form. They are also printed in the person view and in exports.
|
||||
|
||||
Custom fields and custom fields group
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Custom fields are associated to a custom fields group. When a user want to add custom fields on an entity, he must first create a custom fields group and associate this field with an entity. Then he may add add custom fields to this groups.
|
||||
|
||||
Some entities needs a **default** custom fields group. For instance, the default custom fields group will be printed on the main form for person, and will be appended on the main person view. Some bundle does not use this feature (i.e. the `report` bundle).
|
||||
|
||||
.. note::
|
||||
|
||||
In the future of the `person bundle`, other custom fields group will be added in forms accessible from the menu, allowing users to completely customize and separate their entities.
|
||||
|
||||
Allow custom fields on an entity
|
||||
--------------------------------
|
||||
|
||||
As a developer, you must allow your users to add custom fields on your entities.
|
||||
|
||||
.. warning::
|
||||
For having custom fields, the class of the entity must contain a variable for storing the custom data. **By convention this variable must be called $cFData**
|
||||
|
||||
|
||||
Create a json field on your entity
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Declare a json field in your database :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
Chill\CustomFieldsBundle\Entity\BlopEntity:
|
||||
type: entity
|
||||
# ...
|
||||
fields:
|
||||
cFData:
|
||||
type: json_array
|
||||
|
||||
Create the field accordingly in the class logic :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\CustomFieldsBundle\Entity;
|
||||
|
||||
/**
|
||||
* BlopEntity
|
||||
*/
|
||||
class BlopEntity
|
||||
{
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $cFData;
|
||||
|
||||
/**
|
||||
* You must set a setter in order to save automatically custom
|
||||
* fields from forms, using Form Component
|
||||
*
|
||||
* @param array $cFData
|
||||
* @return BlopEntity
|
||||
*/
|
||||
public function setCFData(array $cFData)
|
||||
{
|
||||
$this->cFData = $cFData;
|
||||
return $this;
|
||||
}
|
||||
|
||||
/**
|
||||
* You also must create a getter in order to let Form
|
||||
* component populate form fields
|
||||
*
|
||||
* @return array
|
||||
*/
|
||||
public function getCFData()
|
||||
{
|
||||
return $this->cFData;
|
||||
}
|
||||
|
||||
Declare your customizable entity in configuration
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This step is necessary to allow user to create custom fields group associated with this entity.
|
||||
|
||||
Two methods are available.
|
||||
|
||||
The recommended method is to do it in DependencyInjection/Extension class. It is recommended as your bundle will be well set up (for custom field) in every chill installation that use it.
|
||||
|
||||
The discouraged method is to declare via the app/config.yml file. This is very quick to set up for a given chill installation but it is not done automatically : in every chill installation that use your bundle, this step has to be performed.
|
||||
|
||||
In app/config.yml file (discouraged)
|
||||
""""""""""""""""""""""""""""""""""""
|
||||
|
||||
This method is discouraged but explained first as it helps to undersand the recommended method.
|
||||
|
||||
Add those file under `chill_custom_fields` section :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_custom_fields:
|
||||
customizables_entities:
|
||||
- { class: Chill\YourBundleBundle\Entity\BlopEntity, name: blop_entity }
|
||||
|
||||
* The `name` allow you to define a string which is translatable. This string will appears when chill's admin will add/retrieve new customFieldsGroup.
|
||||
* The class, which is a full FQDN class path
|
||||
|
||||
Automatically, in DependencyInjection/Extension class (recommended)
|
||||
"""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""""
|
||||
|
||||
This is the recommended way for declaring customizable classes.
|
||||
|
||||
You can prepend configuration of `custom fields bundle` from the class `YourBundle\DependencyInjection\YourBundleExtension`. **Note** that you also have to implements `Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface` on this class to make the `prepend` function being taken into account.
|
||||
|
||||
Example here :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
class ChillYourBundleExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
if (!isset($bundles['ChillCustomFieldsBundle'])) {
|
||||
throw new MissingBundleException('ChillCustomFieldsBundle');
|
||||
}
|
||||
|
||||
$container->prependExtensionConfig('chill_custom_fields',
|
||||
array('customizables_entities' =>
|
||||
array(
|
||||
array(
|
||||
'class' => 'Chill\YourBundleBundle\Entity\BlopEntity',
|
||||
'name' => 'blop_entity',)
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
* The `name` allow you to define a string which is translatable. This string will appears when chill's admin will add/retrieve new customFieldsGroup.
|
||||
* The class, which is a full FQDN class path
|
||||
|
||||
.. seealso::
|
||||
|
||||
`How to simplify configuration of multiple bundles <http://symfony.com/doc/current/cookbook/bundles/prepend_extension.html>`_
|
||||
A cookbook page about prepending configuration.
|
||||
|
||||
|
||||
Adding options to your custom fields groups
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
You may add options to the groups associated with an entity.
|
||||
|
||||
In `config.yml` the declaration should be :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_custom_fields:
|
||||
customizables_entities:
|
||||
-
|
||||
class: Chill\YourBundleBundle\Entity\BlopEntity
|
||||
name: BlopEntity
|
||||
options:
|
||||
# this will create a "myFieldKey" field as text, with a maxlength attribute to 150 (see http://symfony.com/doc/master/reference/forms/types/text.html)
|
||||
myFieldKey: {form_type: text, form_options: {attr: [maxlength: 150]}}
|
||||
|
||||
In the `PrependExtensionInterface::prepend` function, the options key will be added in the configuration definition :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
class ChillYourBundleExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
if (!isset($bundles['ChillCustomFieldsBundle'])) {
|
||||
throw new MissingBundleException('ChillCustomFieldsBundle');
|
||||
}
|
||||
|
||||
$container->prependExtensionConfig('chill_custom_fields',
|
||||
array('customizables_entities' =>
|
||||
array(
|
||||
array(
|
||||
'class' => 'Chill\YourBundleBundle\Entity\BlopEntity',
|
||||
'name' => 'BlopEntity',
|
||||
'options' => array(
|
||||
'myFieldKey' => [ 'form_type' => 'text', 'form_options' => [ 'attr' => [ 'maxlength' => 150 ] ]
|
||||
))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
**Example :** the entity `Report` from **ReportBundle** has to pick some custom fields belonging to a group to print them in *summaries* the timeline page. The definition will use the special type `custom_fields_group_linked_custom_field` which will add a select input with all fields associated with the current custom fields group :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
class ChillReportExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
*
|
||||
*
|
||||
* @param ContainerBuilder $container
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$bundles = $container->getParameter('kernel.bundles');
|
||||
if (!isset($bundles['ChillCustomFieldsBundle'])) {
|
||||
throw new MissingBundleException('ChillCustomFieldsBundle');
|
||||
}
|
||||
|
||||
$container->prependExtensionConfig('chill_custom_fields',
|
||||
array('customizables_entities' =>
|
||||
array(
|
||||
array(
|
||||
'class' => 'Chill\ReportBundle\Entity\Report',
|
||||
'name' => 'ReportEntity',
|
||||
'options' => array(
|
||||
'summary_fields' => array(
|
||||
'form_type' => 'custom_fields_group_linked_custom_fields',
|
||||
'form_options' =>
|
||||
[
|
||||
'multiple' => true,
|
||||
'expanded' => false
|
||||
]
|
||||
)
|
||||
))
|
||||
)
|
||||
)
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
Note that `custom_fields_group_linked_custom_fields` does not create any input on `CustomFieldsGroup` creation : there aren't any fields associated with the custom fields just after the group creation... You have to add custom fields and associate them with the newly created group to see them appears.
|
||||
|
||||
Rendering custom fields and custom fields group in a template
|
||||
-------------------------------------------------------------
|
||||
|
||||
.. warning::
|
||||
Each custom field can be `active` or not. Only `active` custom fields has to be dislayed.
|
||||
|
||||
For rendering custom fields, two function are available :
|
||||
|
||||
* `chill_custom_field_widget` to render the widget. This function is defined on a customFieldType basis.
|
||||
* `chill_custom_field_label` to render the label. You can customize the label rendering by choosing the layout you would like to use.
|
||||
* `chill_custom_field_is_empty` indicates if the content of the custom fields is empty (return a boolean)
|
||||
|
||||
For rendering custom fields group, a function is available :
|
||||
|
||||
* `chill_custom_fields_group_widget` to render the widget. It will display the custom fields of the group in a dd / dt structure.
|
||||
|
||||
chill_custom_field_label
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The signature is :
|
||||
|
||||
* `CustomField` **$customField** a customField instance
|
||||
* `array` **params** the parameters for rendering. Currently, 'label_layout' allow to choose a different label. Default is 'ChillCustomFieldsBundle:CustomField:render_label.html.twig'
|
||||
|
||||
Examples
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ chill_custom_field_label(customField) }}
|
||||
|
||||
|
||||
|
||||
chill_custom_field_widget
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The signature is :
|
||||
|
||||
* array **$fields** the array raw, as stored in the db
|
||||
* CustomField **$customField** a customField instance
|
||||
* string **$documentType** the type of document. Default to `html`.
|
||||
|
||||
Examples:
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ chill_custom_field_widget(entity.customFields, customField) }}
|
||||
|
||||
chill_custom_field_is_empty
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The signature is :
|
||||
|
||||
* array **$fields** the array raw, as stored in the db
|
||||
* CustomField **$customField** a customField instance
|
||||
|
||||
Examples :
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{%- if chill_custom_field_is_empty(cFData, customField) == false -%}
|
||||
|
||||
|
||||
chill_custom_fields_group_widget
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This function only display custom fields that are `active`.
|
||||
|
||||
The signature is :
|
||||
|
||||
* array **$fields** the array raw, as stored in the db
|
||||
* CustomFieldsGroup **$customFieldsGroup** the custom field group to render
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ chill_custom_fields_group_widget(entity.cFData, entity.customFieldsGroup) }}
|
||||
|
||||
Custom Fields's form
|
||||
--------------------
|
||||
|
||||
You should simply use the 'custom_field' type in a template, with the group you would like to render in the `group` option's type.
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\ReportBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolverInterface;
|
||||
|
||||
class ReportType extends AbstractType
|
||||
{
|
||||
/**
|
||||
* @param FormBuilderInterface $builder
|
||||
* @param array $options
|
||||
*/
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$entityManager = $options['em'];
|
||||
|
||||
$builder
|
||||
->add('user')
|
||||
->add('date', 'date',
|
||||
array('required' => true, 'widget' => 'single_text', 'format' => 'dd-MM-yyyy'))
|
||||
#add the custom fields :
|
||||
->add('cFData', 'custom_field',
|
||||
array('attr' => array('class' => 'cf-fields'), 'group' => $options['cFGroup']))
|
||||
;
|
||||
}
|
||||
|
||||
/**
|
||||
* @param OptionsResolverInterface $resolver
|
||||
*/
|
||||
public function setDefaultOptions(OptionsResolverInterface $resolver)
|
||||
{
|
||||
$resolver->setDefaults(array(
|
||||
'data_class' => 'Chill\ReportBundle\Entity\Report'
|
||||
));
|
||||
|
||||
$resolver->setRequired(array(
|
||||
'em',
|
||||
'cFGroup',
|
||||
));
|
||||
|
||||
$resolver->setAllowedTypes(array(
|
||||
'em' => 'Doctrine\Common\Persistence\ObjectManager',
|
||||
'cFGroup' => 'Chill\CustomFieldsBundle\Entity\CustomFieldsGroup'
|
||||
));
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getName()
|
||||
{
|
||||
return 'chill_reportbundle_report';
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Available configuration
|
||||
------------------------
|
||||
|
||||
Those options are available in the configuration, under the `chill_custom_field` key.
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_custom_field:
|
||||
show_empty_values_in_views: false
|
||||
|
||||
show_empty_values_in_views *boolean*:
|
||||
Allow to hide / show empty values in views. The aim of this configuration parameter is to hide (or show) empty values when :term:`custom fields group` are rendered.
|
||||
|
||||
Default value : `true`
|
||||
|
||||
Glossary
|
||||
--------
|
||||
|
||||
.. glossary::
|
||||
|
||||
custom fields group
|
||||
A group of custom fields
|
29
docs/source/bundles/event.rst
Normal file
@ -0,0 +1,29 @@
|
||||
.. Copyright (C) 2016 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _event-bundle:
|
||||
|
||||
Event bundle
|
||||
############
|
||||
|
||||
Template & Menu
|
||||
===============
|
||||
|
||||
The event bundle has a special template with a specific menu for actions on
|
||||
events. This menu is called `event`.
|
||||
|
||||
ChillEventBundle::layout.html.twig
|
||||
----------------------------------
|
||||
|
||||
This layout extends `ChillMainBundle::layoutWithVerticalMenu.html.twig` and add the menu `event`
|
||||
|
||||
It proposes a new block :
|
||||
|
||||
* event_content
|
||||
|
||||
* where to display content relative to the event.
|
49
docs/source/bundles/group.rst
Normal file
@ -0,0 +1,49 @@
|
||||
.. Copyright (C) 2016 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _group-bundle:
|
||||
|
||||
Group bundle
|
||||
############
|
||||
|
||||
Allow to group people in a group. This group may be a family, an activity group, ...
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
Entities
|
||||
********
|
||||
|
||||
.. figure:: /_static/bundles/group/group_classes_uml.png
|
||||
|
||||
|
||||
.. _group-bundle-macros:
|
||||
|
||||
Macros
|
||||
******
|
||||
|
||||
Group sticker
|
||||
==============
|
||||
|
||||
Macro file
|
||||
`ChillGroupBundle:Group:macro.html.twig`
|
||||
Macro name
|
||||
:code:`_render`
|
||||
Macro envelope
|
||||
:code:`group`, instance of :class:`Chill\GroupBundle\Entity\CGroup`
|
||||
|
||||
When to use this macro ?
|
||||
When you want to represent group.
|
||||
Example usage :
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{% import 'ChillGroupBundle:Group:macro.html.twig' as m %}
|
||||
|
||||
{{ m._render(g) }}
|
||||
|
||||
|
29
docs/source/bundles/index.rst
Normal file
@ -0,0 +1,29 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Bundles documentation
|
||||
###############################
|
||||
|
||||
You will find here documentation about bundles working with Chill.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
Main bundle <main.rst>
|
||||
Custom Fields bundle <custom-fields.rst>
|
||||
Person bundle <person.rst>
|
||||
Report bundle <report.rst>
|
||||
Activity bundle <activity.rst>
|
||||
Group bundle <group.rst>
|
||||
Event bundle <event.rst>
|
||||
Ldap bundle (synchronisation between ldap and database) <ldap.rst>
|
||||
|
||||
Your bundle here ?
|
||||
-------------------
|
||||
|
||||
The contributors still do not have a policy about those bundle integration, but we would like to be very open on this subject. Please write to us `or open an issue <https://redmine.champs-libres.coop/projects/chill/issues>`_.
|
204
docs/source/bundles/ldap.rst
Normal file
@ -0,0 +1,204 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _ldap-bundle:
|
||||
|
||||
LDAP bundle
|
||||
###########
|
||||
|
||||
This bundle binds the database with an ldap directory.
|
||||
|
||||
The bundle synchronize the ldap directory with users in the database. It also
|
||||
provides a way to check user credentials against the ldap directory.
|
||||
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
Current limitations
|
||||
*******************
|
||||
|
||||
- The length of the ldap dn must be < 255 characters
|
||||
- if the username extracted from the ldap is updated, the changes are not reflected in the database and remains the same
|
||||
|
||||
|
||||
Entities provided
|
||||
*****************
|
||||
|
||||
This bundle provides only one entity : :class:`Chill\\LdapBundle\\Entity\\UserLdapBinding`
|
||||
|
||||
How the synchronizer works ?
|
||||
****************************
|
||||
|
||||
#. The synchronizer performs a query on :code:`dn` and :code:`query` defined in the :ref:`configuration <configuration>`.
|
||||
#. For each entry returned by the query, it looks if the :code:`dn` exists in the database
|
||||
|
||||
#. If the entry does not exists :
|
||||
|
||||
#. the synchronizer looks for user with same username as defined by :code:`username_attr`, and bind it with the :code:`dn` if it exists.
|
||||
#. else, a user is created with username defined by :code:`username_attr` (if the ldap contains more than one attribute, the first attribute returned is used)
|
||||
|
||||
#. if a user exists which is already binded with the :code:`dn`, the entry is ignored.
|
||||
|
||||
#. The synchronizer looks for dn existing in database and which were not returned by the query performed in 1.
|
||||
|
||||
#. If they exists, those user are set to :code:`enabled=false`: they are not allowed to login.
|
||||
|
||||
Installation
|
||||
************
|
||||
|
||||
This bundle requires :
|
||||
|
||||
- PHP LDAP ext
|
||||
- :code:`symfony/ldap` with minimal version 3.1. Note that, currently, Chill uses Symfony 2.8: you should add the dependency on this single package manually
|
||||
|
||||
In your composer.json, for stable version :
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
"require": {
|
||||
// .. other dependencies
|
||||
"symfony/ldap" : "~3.1",
|
||||
"chill-project/ldap": "~1.0"
|
||||
}
|
||||
|
||||
|
||||
|
||||
And for dev version :
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
"require": {
|
||||
// .. other dependencies
|
||||
"symfony/ldap" : "~3.1",
|
||||
"chill-project/ldap": "dev-master@dev"
|
||||
}
|
||||
|
||||
|
||||
.. _configuration:
|
||||
|
||||
Configuration
|
||||
**************
|
||||
|
||||
Configuration of the bundle
|
||||
============================
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# Default configuration for extension with alias: "chill_ldap"
|
||||
chill_ldap:
|
||||
server: # Required
|
||||
|
||||
# the host of the ldap directory
|
||||
host: ~ # Required, Example: localhost
|
||||
|
||||
# the port to reach the ldap directory
|
||||
port: 389
|
||||
|
||||
# the version of the ldap directory
|
||||
version: 3
|
||||
|
||||
# Is the use of ssl required to establish connection
|
||||
use_ssl: false
|
||||
|
||||
# Is the use of startssl required to establish connection
|
||||
use_starttls: false
|
||||
|
||||
# the user to bind to dn directory. Required for searching existing users.
|
||||
bind_dn: ~ # Required, Example: cn=user,dn=chill,dn=social
|
||||
|
||||
# the user's password to bind to dn directory.
|
||||
bind_password: ~ # Required, Example: paSSw0rD
|
||||
user_query: # Required
|
||||
|
||||
# The DN where the query is executed
|
||||
dn: ~ # Example: ou=People,dc=champs-libres,dc=coop
|
||||
|
||||
# The query which will allow to retrieve users
|
||||
query: ~ # Example: (&(objectClass=inetOrgPerson)(userPassword=*))
|
||||
|
||||
# The attribute which will provide username (=login)
|
||||
username_attr: cn
|
||||
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_ldap:
|
||||
server:
|
||||
# host, bind_dn and bind_password are imported from parameters.yml
|
||||
host: "%ldap_host%"
|
||||
bind_dn: "%ldap_bind_dn%"
|
||||
bind_password: "%ldap_bind_password%"
|
||||
user_query:
|
||||
dn: dc=champs-libres,dc=coop
|
||||
query: "(&(objectClass=inetOrgPerson)(userPassword=*))"
|
||||
|
||||
|
||||
Configuration of the security part of chill
|
||||
============================================
|
||||
|
||||
Simply add the following config in the firewall of the security bundle :
|
||||
`chill_ldap_form_login: ~`. This config is located in `app/config/security.yml`
|
||||
|
||||
Example of a configuration :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# in app/config/security.yml
|
||||
|
||||
firewalls:
|
||||
dev:
|
||||
pattern: ^/(_(profiler|wdt)|css|images|js)/
|
||||
security: false
|
||||
|
||||
default:
|
||||
anonymous: ~
|
||||
# enable the login check by a form, agaisnt the database
|
||||
form_login:
|
||||
csrf_parameter: _csrf_token
|
||||
csrf_token_id: authenticate
|
||||
csrf_provider: form.csrf_provider
|
||||
# enable the login check by a form, against the ldap
|
||||
chill_ldap_form_login: ~ # this is the line you should add
|
||||
|
||||
|
||||
Note that, if you enable the login check by form **and** by the ldap,
|
||||
the password will be checked against the database **and** against the ldap.
|
||||
If one of them match, the login will succeed.
|
||||
|
||||
If you want to completely disable login check against the database,
|
||||
simply remove the :code:`form_login` entry and all his options.
|
||||
|
||||
.. _command-and-crontab:
|
||||
|
||||
Command and crontab
|
||||
===================
|
||||
|
||||
Synchronize the database :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
php app/console chill:ldap:synchronize
|
||||
|
||||
|
||||
For getting more debug message :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
php app/console chill:ldap:synchronize -vvv
|
||||
|
||||
|
||||
|
||||
You should run this command regularly (using crontab or
|
||||
`systemd timer <https://www.freedesktop.org/software/systemd/man/systemd.timer.html#>`_)
|
||||
to synchronize ldap and database automatically.
|
||||
|
||||
|
||||
|
49
docs/source/bundles/main.rst
Normal file
@ -0,0 +1,49 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _main-bundle:
|
||||
|
||||
Main bundle
|
||||
###########
|
||||
|
||||
This bundle is **required** for running Chill.
|
||||
|
||||
This bundle provide :
|
||||
|
||||
* Access control model (users, groups, and all concepts)
|
||||
* ...
|
||||
|
||||
|
||||
.. warning::
|
||||
|
||||
this section is incomplete.
|
||||
|
||||
.. _main-bundle-macros:
|
||||
|
||||
Macros
|
||||
******
|
||||
|
||||
Address sticker
|
||||
===============
|
||||
|
||||
Macro file
|
||||
`ChillMainBundle:Address:macro.html.twig`
|
||||
Macro name
|
||||
:code:`_render`
|
||||
Macro envelope
|
||||
:code:`address`, instance of :class:`Chill\MainBundle\Entity\Address`
|
||||
|
||||
When to use this macro ?
|
||||
When you want to represent an address.
|
||||
Example usage :
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{% import 'ChillMainBundle:Address:macro.html.twig' as m %}
|
||||
|
||||
{{ m._render(address) }}
|
||||
|
233
docs/source/bundles/person.rst
Normal file
@ -0,0 +1,233 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _person-bundle:
|
||||
|
||||
Person bundle
|
||||
#############
|
||||
|
||||
This bundle provides the ability to record people in the software. This bundle is required by other bundle.
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
Entities provided
|
||||
*****************
|
||||
|
||||
.. todo::
|
||||
|
||||
describe entities provided by person bundle
|
||||
|
||||
|
||||
Search terms
|
||||
************
|
||||
|
||||
The class `Chill\PersonBundle\Search\PersonSearch` provide the search module.
|
||||
|
||||
Domain
|
||||
======
|
||||
|
||||
The search upon "person" is provided by default. The `@person` domain search may be omitted.
|
||||
|
||||
* `@person` is the domain search for people.
|
||||
|
||||
|
||||
Arguments
|
||||
=========
|
||||
|
||||
* `firstname` : provide the search on firstname. Example : `firstname:Depardieu`. May match part of the firstname (`firsname:dep` will match Depardieu)
|
||||
* `lastname` : provide the search on lastname. May match part of the lastname.
|
||||
* `birthdate` : provide the search on the birthdate. Example : `birthdate:1996-01-19`
|
||||
* `gender`: performs search on man/woman. The accepted values are `man` or `woman`.
|
||||
* `nationality` : performs search on nationality. Value must be a country code `as described in ISO 3166 <http://www.iso.org/iso/fr/home/standards/country_codes.htm>`_. Example : `nationality:FR`.
|
||||
|
||||
Default
|
||||
=======
|
||||
|
||||
The default search is performed on firstname and/or lastname. Both are concatened before search. If values are separated by spaces, the clause `AND` is used : the search `dep ge` will match 'Gérard Depardieu` or 'Jean Depagelles', but not 'Charline Depardieu' (missing 'Ge' in word).
|
||||
|
||||
Configuration options
|
||||
*********************
|
||||
|
||||
Those options are available under `chill_person` key.
|
||||
|
||||
Example of configuration:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_person:
|
||||
validation:
|
||||
birthdate_not_after: P15Y
|
||||
person_fields:
|
||||
# note: visible is the default config. This key may be omitted if visible is chosen.
|
||||
nationality: hidden
|
||||
email: hidden
|
||||
place_of_birth: visible
|
||||
phonenumber: hidden
|
||||
country_of_birth: hidden
|
||||
marital_status: visible
|
||||
spoken_languages: hidden
|
||||
address: visible
|
||||
|
||||
birthdate_not_after *string*
|
||||
The period duration before today during which encoding birthdate is not possible. The period is a string matching the format of `ISO_8601`, which is also use to build `DateInterval classes <http://php.net/manual/en/dateinterval.construct.php>`_.
|
||||
|
||||
Example: `P1D`, `P18Y`
|
||||
|
||||
Default value: `P1D` which means that birthdate before the current day (= yesterday) are allowed.
|
||||
|
||||
person_fields *array*
|
||||
This define the visibility of some fields. By default, all fields are visible, but you can choose to hide some of them. Available keys are :
|
||||
|
||||
* `nationality`
|
||||
* `country_of_birth`
|
||||
* `place_of_birth`
|
||||
* `phonenumber`
|
||||
* `email`
|
||||
* `marital_status`
|
||||
* `spoken_languages`
|
||||
* `address`
|
||||
|
||||
Possibles values: `hidden` or `visible` (all other value will raise an Exception).
|
||||
|
||||
Default value : `visible`, which means that all fields are visible.
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_person:
|
||||
person_fields:
|
||||
nationality: hidden
|
||||
email: hidden
|
||||
phonenumber: hidden
|
||||
|
||||
.. note::
|
||||
If all the field of a "box" are hidden, the whole box does not appears. Example: if the fields `phonenumber` and `email` are hidden, the title `Contact information` will be hidden in the UI.
|
||||
|
||||
.. note::
|
||||
If you hide multiple fields, for a better integration you may want to override the template, for a better appeareance. See `the symfony documentation <http://symfony.com/doc/current/book/templating.html#overriding-bundle-templates>`_ about this feature.
|
||||
|
||||
.. _person-bundle-macros:
|
||||
|
||||
Macros
|
||||
******
|
||||
|
||||
Sticker for a person
|
||||
=====================
|
||||
|
||||
Macro file
|
||||
`ChillPersonBundle:Person:macro.html.twig`
|
||||
Macro envelope
|
||||
:code:`render(p, withLink=false)`
|
||||
|
||||
:code:`p` is an instance of :class:`Chill\PersonBundle\Entity\Person`
|
||||
|
||||
:code:`withLink` :class:`boolean`
|
||||
When to use this macro ?
|
||||
When you want to represent a person.
|
||||
Example usage :
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{% import "ChillPersonBundle:Person:macro.html.twig" as person_ %}
|
||||
|
||||
{{ person_.render(person, true) }}
|
||||
|
||||
Layout events and delegated blocks
|
||||
***********************************
|
||||
|
||||
:code:`chill_block.person_post_vertical_menu` event
|
||||
====================================================
|
||||
|
||||
This event is available to add content below of the vertical menu (on the right).
|
||||
|
||||
The context is :
|
||||
|
||||
- :code:`person` : the current person which is rendered. Instance of :class:`Chill\PersonBundle\Entity\Person`
|
||||
|
||||
Widgets
|
||||
*******
|
||||
|
||||
Add a list of person on homepage
|
||||
================================
|
||||
|
||||
The bundle provide a way to add a list of accompanyied person on the homepage:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_main:
|
||||
widgets:
|
||||
homepage:
|
||||
-
|
||||
order: 10
|
||||
widget_alias: person_list
|
||||
person_list:
|
||||
# customize the number of items
|
||||
number_of_items: 20
|
||||
|
||||
# only active
|
||||
only_active: true
|
||||
|
||||
# you can add some filtering class, which will implements
|
||||
# Chill\PersonBundle\PersonListWidget\PersonFilteringInterface
|
||||
filtering_class: "\Hepc\HomepagePersonFiltering"
|
||||
|
||||
# when the view is overriden, you can add some custom fields
|
||||
# to the view
|
||||
custom_fields: [school-2fb5440e-192c-11e6-b2fd-74d02b0c9b55]
|
||||
|
||||
Commands
|
||||
********
|
||||
|
||||
|
||||
:code:`chill:person:move`
|
||||
=========================
|
||||
|
||||
.. code-block:: txt
|
||||
|
||||
Usage:
|
||||
chill:person:move [options]
|
||||
|
||||
Options:
|
||||
-f, --from=FROM The person id to delete, all associated data will be moved before
|
||||
-t, --to=TO The person id which will received data
|
||||
--dump-sql dump sql to stdout
|
||||
--force execute sql instead of dumping it
|
||||
-h, --help Display this help message
|
||||
-q, --quiet Do not output any message
|
||||
-V, --version Display this application version
|
||||
--ansi Force ANSI output
|
||||
--no-ansi Disable ANSI output
|
||||
-n, --no-interaction Do not ask any interactive question
|
||||
-e, --env=ENV The Environment name. [default: "dev"]
|
||||
--no-debug Switches off debug mode.
|
||||
-v|vv|vvv, --verbose Increase the verbosity of messages: 1 for normal output, 2 for more verbose output and 3 for debug
|
||||
|
||||
Help:
|
||||
Move all the associated entities on a "from" person to a "to" person and remove the old person
|
||||
|
||||
Move all the entities associated to a person onto another one, and remove the old person.
|
||||
|
||||
.. warning::
|
||||
|
||||
Some entities are ignored and will be deleted:
|
||||
|
||||
- the accompanying periods ;
|
||||
- the data attached to a person entity: name, address, date of birth, etc. Thos should be merge before the move.
|
||||
|
||||
It is advised to run first the command with the :code:`dump-sql` option and, then, use the :code:`force` option.
|
||||
|
||||
The moving and suppression is executed inside a transaction, ensuring no data loss if the migration fails.
|
||||
|
||||
.. note::
|
||||
|
||||
Using bash and awk, it is easy to use a TSV file (values separated by a tab, not a comma) to create move commands. Assuming our file is named :code:`twins.tsv` and contains two columns: the first one with :code:`from` ids, and the second one with :code:`to` ids:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
awk '{ print "php app/console chill:person:move --dump-sql --from " $1 " --to " $2;}' twins.tsv
|
46
docs/source/bundles/report.rst
Normal file
@ -0,0 +1,46 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _report-bundle:
|
||||
|
||||
Report bundle
|
||||
#############
|
||||
|
||||
This bundle provides the ability to record report about people. We use custom fields to let user add fields to reports.
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
.. todo::
|
||||
|
||||
The documentation about report is not writtend
|
||||
|
||||
Concepts
|
||||
========
|
||||
|
||||
|
||||
Search
|
||||
======
|
||||
|
||||
Domain
|
||||
------
|
||||
|
||||
* `@report` is the domain search for reports.
|
||||
|
||||
|
||||
Arguments
|
||||
---------
|
||||
|
||||
* `date` : The date of the report
|
||||
|
||||
Default
|
||||
-------
|
||||
|
||||
The report's date is the default value.
|
||||
|
||||
An error is thrown if an argument `date` and a default is used.
|
415
docs/source/conf.py
Normal file
@ -0,0 +1,415 @@
|
||||
#!/usr/bin/env python3
|
||||
# -*- coding: utf-8 -*-
|
||||
#
|
||||
# chill-doc documentation build configuration file, created by
|
||||
# sphinx-quickstart on Sun Sep 28 22:04:08 2014.
|
||||
#
|
||||
# This file is execfile()d with the current directory set to its
|
||||
# containing dir.
|
||||
#
|
||||
# Note that not all possible configuration values are present in this
|
||||
# autogenerated file.
|
||||
#
|
||||
# All configuration values have a default; values that are commented out
|
||||
# serve to show the default.
|
||||
|
||||
import sys
|
||||
import os
|
||||
|
||||
# on_rtd is whether we are on readthedocs.org, this line of code grabbed from docs.readthedocs.org
|
||||
on_rtd = os.environ.get('READTHEDOCS', None) == 'True'
|
||||
|
||||
# If extensions (or modules to document with autodoc) are in another directory,
|
||||
# add these directories to sys.path here. If the directory is relative to the
|
||||
# documentation root, use os.path.abspath to make it absolute, like shown here.
|
||||
#sys.path.insert(0, os.path.abspath('.'))
|
||||
|
||||
if not on_rtd:
|
||||
sys.path.append(os.path.abspath('./../_exts/sphinx-php'))
|
||||
|
||||
|
||||
# adding PhpLexer
|
||||
try:
|
||||
from sphinx.highlighting import lexers
|
||||
from pygments.lexers.compiled import CLexer
|
||||
from pygments.lexers.web import PhpLexer
|
||||
php_lexer_available = True
|
||||
except ImportError:
|
||||
php_lexer_available = False
|
||||
print('specific import not available')
|
||||
|
||||
# -- General configuration ------------------------------------------------
|
||||
|
||||
# If your documentation needs a minimal Sphinx version, state it here.
|
||||
#needs_sphinx = '1.0'
|
||||
|
||||
# Add any Sphinx extension module names here, as strings. They can be
|
||||
# extensions coming with Sphinx (named 'sphinx.ext.*') or your custom
|
||||
# ones.
|
||||
extensions = [
|
||||
'sphinx.ext.autodoc',
|
||||
'sphinx.ext.todo',
|
||||
]
|
||||
|
||||
try:
|
||||
import sensio.sphinx.refinclude
|
||||
except ImportError:
|
||||
print('sensio.sphinx.refinclude is not available')
|
||||
else:
|
||||
extensions += ['sensio.sphinx.refinclude']
|
||||
|
||||
try:
|
||||
import sensio.sphinx.configurationblock
|
||||
except ImportError:
|
||||
print('sensio.sphinx.configurationblock is not available')
|
||||
else:
|
||||
extensions += ['sensio.sphinx.configurationblock']
|
||||
|
||||
try:
|
||||
import sensio.sphinx.phpcode
|
||||
except ImportError:
|
||||
print('sensio.sphinx.phpcode')
|
||||
else:
|
||||
extensions += ['sensio.sphinx.phpcode']
|
||||
|
||||
try:
|
||||
import sensio.sphinx.bestpractice
|
||||
except ImportError:
|
||||
print('sensio.sphinx.bestpractice is not avaialble')
|
||||
else:
|
||||
extensions += ['sensio.sphinx.bestpractice']
|
||||
|
||||
#add configuration for api url
|
||||
|
||||
api_url = 'http://api.chill.social/master/%s'
|
||||
|
||||
# Add any paths that contain templates here, relative to this directory.
|
||||
templates_path = ['_templates']
|
||||
|
||||
# The suffix of source filenames.
|
||||
source_suffix = '.rst'
|
||||
|
||||
# The encoding of source files.
|
||||
#source_encoding = 'utf-8-sig'
|
||||
|
||||
# The master toctree document.
|
||||
master_doc = 'index'
|
||||
|
||||
# General information about the project.
|
||||
project = 'Chill Documentation'
|
||||
copyright = '2014-2016, Champs-Libres, published under the terms of the GNU Free Documentation License, Version 1.3'
|
||||
|
||||
# The version info for the project you're documenting, acts as replacement for
|
||||
# |version| and |release|, also used in various other places throughout the
|
||||
# built documents.
|
||||
#
|
||||
# The short X.Y version.
|
||||
version = '1.0'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.0'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
#language = None
|
||||
|
||||
# There are two options for replacing |today|: either, you set today to some
|
||||
# non-false value, then it is used:
|
||||
#today = ''
|
||||
# Else, today_fmt is used as the format for a strftime call.
|
||||
#today_fmt = '%B %d, %Y'
|
||||
|
||||
# List of patterns, relative to source directory, that match files and
|
||||
# directories to ignore when looking for source files.
|
||||
exclude_patterns = []
|
||||
|
||||
# The reST default role (used for this markup: `text`) to use for all
|
||||
# documents.
|
||||
#default_role = None
|
||||
|
||||
# If true, '()' will be appended to :func: etc. cross-reference text.
|
||||
#add_function_parentheses = True
|
||||
|
||||
# If true, the current module name will be prepended to all description
|
||||
# unit titles (such as .. function::).
|
||||
#add_module_names = True
|
||||
|
||||
# If true, sectionauthor and moduleauthor directives will be shown in the
|
||||
# output. They are ignored by default.
|
||||
#show_authors = False
|
||||
|
||||
# The name of the Pygments (syntax highlighting) style to use.
|
||||
pygments_style = 'sphinx'
|
||||
|
||||
# A list of ignored prefixes for module index sorting.
|
||||
#modindex_common_prefix = []
|
||||
|
||||
# If true, keep warnings as "system message" paragraphs in the built documents.
|
||||
#keep_warnings = False
|
||||
|
||||
# -- Settings for symfony doc extension ---------------------------------------------------
|
||||
if php_lexer_available:
|
||||
# enable highlighting for PHP code not between ``<?php ... ?>`` by default
|
||||
lexers['php'] = PhpLexer(startinline=True)
|
||||
lexers['php-annotations'] = PhpLexer(startinline=True)
|
||||
lexers['php-standalone'] = PhpLexer(startinline=True)
|
||||
lexers['php-symfony'] = PhpLexer(startinline=True)
|
||||
lexers['varnish3'] = CLexer()
|
||||
lexers['varnish4'] = CLexer()
|
||||
config_block = {
|
||||
'varnish3': 'Varnish 3',
|
||||
'varnish4': 'Varnish 4'
|
||||
}
|
||||
# use PHP as the primary domain
|
||||
primary_domain = 'php'
|
||||
# set url for API links
|
||||
api_url = 'http://api.symfony.com/master/%s'
|
||||
|
||||
|
||||
# -- Options for HTML output ----------------------------------------------
|
||||
|
||||
# The theme to use for HTML and HTML Help pages. See the documentation for
|
||||
# a list of builtin themes.
|
||||
html_theme = 'default' #overriden if run locally, see end of file
|
||||
|
||||
# Theme options are theme-specific and customize the look and feel of a theme
|
||||
# further. For a list of options available for each theme, see the
|
||||
# documentation.
|
||||
#html_theme_options = {}
|
||||
|
||||
# Add any paths that contain custom themes here, relative to this directory.
|
||||
#html_theme_path = []
|
||||
|
||||
# The name for this set of Sphinx documents. If None, it defaults to
|
||||
# "<project> v<release> documentation".
|
||||
#html_title = None
|
||||
|
||||
# A shorter title for the navigation bar. Default is the same as html_title.
|
||||
#html_short_title = None
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top
|
||||
# of the sidebar.
|
||||
#html_logo = None
|
||||
|
||||
# The name of an image file (within the static path) to use as favicon of the
|
||||
# docs. This file should be a Windows icon file (.ico) being 16x16 or 32x32
|
||||
# pixels large.
|
||||
#html_favicon = None
|
||||
|
||||
# Add any paths that contain custom static files (such as style sheets) here,
|
||||
# relative to this directory. They are copied after the builtin static files,
|
||||
# so a file named "default.css" will overwrite the builtin "default.css".
|
||||
html_static_path = ['_static']
|
||||
|
||||
# Add any extra paths that contain custom files (such as robots.txt or
|
||||
# .htaccess) here, relative to this directory. These files are copied
|
||||
# directly to the root of the documentation.
|
||||
#html_extra_path = []
|
||||
|
||||
# If not '', a 'Last updated on:' timestamp is inserted at every page bottom,
|
||||
# using the given strftime format.
|
||||
#html_last_updated_fmt = '%b %d, %Y'
|
||||
|
||||
# If true, SmartyPants will be used to convert quotes and dashes to
|
||||
# typographically correct entities.
|
||||
#html_use_smartypants = True
|
||||
|
||||
# Custom sidebar templates, maps document names to template names.
|
||||
#html_sidebars = {}
|
||||
|
||||
# Additional templates that should be rendered to pages, maps page names to
|
||||
# template names.
|
||||
#html_additional_pages = {}
|
||||
|
||||
# If false, no module index is generated.
|
||||
#html_domain_indices = True
|
||||
|
||||
# If false, no index is generated.
|
||||
#html_use_index = True
|
||||
|
||||
# If true, the index is split into individual pages for each letter.
|
||||
#html_split_index = False
|
||||
|
||||
# If true, links to the reST sources are added to the pages.
|
||||
#html_show_sourcelink = True
|
||||
|
||||
# If true, "Created using Sphinx" is shown in the HTML footer. Default is True.
|
||||
#html_show_sphinx = True
|
||||
|
||||
# If true, "(C) Copyright ..." is shown in the HTML footer. Default is True.
|
||||
#html_show_copyright = True
|
||||
|
||||
# If true, an OpenSearch description file will be output, and all pages will
|
||||
# contain a <link> tag referring to it. The value of this option must be the
|
||||
# base URL from which the finished HTML is served.
|
||||
#html_use_opensearch = ''
|
||||
|
||||
# This is the file name suffix for HTML files (e.g. ".xhtml").
|
||||
#html_file_suffix = None
|
||||
|
||||
# Output file base name for HTML help builder.
|
||||
htmlhelp_basename = 'chill-docdoc'
|
||||
|
||||
|
||||
# -- Options for LaTeX output ---------------------------------------------
|
||||
|
||||
latex_elements = {
|
||||
# The paper size ('letterpaper' or 'a4paper').
|
||||
#'papersize': 'letterpaper',
|
||||
'papersize': 'a4paper'
|
||||
|
||||
# The font size ('10pt', '11pt' or '12pt').
|
||||
#'pointsize': '10pt',
|
||||
|
||||
# Additional stuff for the LaTeX preamble.
|
||||
#'preamble': '',
|
||||
}
|
||||
|
||||
# Grouping the document tree into LaTeX files. List of tuples
|
||||
# (source start file, target name, title,
|
||||
# author, documentclass [howto, manual, or own class]).
|
||||
latex_documents = [
|
||||
('index', 'chill-doc.tex', 'chill-doc Documentation',
|
||||
'Champs-Libres', 'manual'),
|
||||
]
|
||||
|
||||
# The name of an image file (relative to this directory) to place at the top of
|
||||
# the title page.
|
||||
#latex_logo = None
|
||||
|
||||
# For "manual" documents, if this is true, then toplevel headings are parts,
|
||||
# not chapters.
|
||||
#latex_use_parts = False
|
||||
|
||||
# If true, show page references after internal links.
|
||||
#latex_show_pagerefs = False
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#latex_show_urls = False
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#latex_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#latex_domain_indices = True
|
||||
|
||||
|
||||
# -- Options for manual page output ---------------------------------------
|
||||
|
||||
# One entry per manual page. List of tuples
|
||||
# (source start file, name, description, authors, manual section).
|
||||
man_pages = [
|
||||
('index', 'chill-doc', 'chill-doc Documentation',
|
||||
['Champs-Libres'], 1)
|
||||
]
|
||||
|
||||
# If true, show URL addresses after external links.
|
||||
#man_show_urls = False
|
||||
|
||||
|
||||
# -- Options for Texinfo output -------------------------------------------
|
||||
|
||||
# Grouping the document tree into Texinfo files. List of tuples
|
||||
# (source start file, target name, title, author,
|
||||
# dir menu entry, description, category)
|
||||
texinfo_documents = [
|
||||
('index', 'chill-doc', 'chill-doc Documentation',
|
||||
'Champs-Libres', 'chill-doc', 'One line description of project.',
|
||||
'Miscellaneous'),
|
||||
]
|
||||
|
||||
# Documents to append as an appendix to all manuals.
|
||||
#texinfo_appendices = []
|
||||
|
||||
# If false, no module index is generated.
|
||||
#texinfo_domain_indices = True
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#texinfo_show_urls = 'footnote'
|
||||
|
||||
# If true, do not generate a @detailmenu in the "Top" node's menu.
|
||||
#texinfo_no_detailmenu = False
|
||||
|
||||
|
||||
# -- Options for Epub output ----------------------------------------------
|
||||
|
||||
# Bibliographic Dublin Core info.
|
||||
epub_title = 'Chill Documentation'
|
||||
epub_author = 'Champs-Libres'
|
||||
epub_publisher = 'Champs-Libres'
|
||||
epub_copyright = '2014-2016, Champs-Libres'
|
||||
|
||||
# The basename for the epub file. It defaults to the project name.
|
||||
#epub_basename = 'chill-doc'
|
||||
|
||||
# The HTML theme for the epub output. Since the default themes are not optimized
|
||||
# for small screen space, using the same theme for HTML and epub output is
|
||||
# usually not wise. This defaults to 'epub', a theme designed to save visual
|
||||
# space.
|
||||
#epub_theme = 'epub'
|
||||
|
||||
# The language of the text. It defaults to the language option
|
||||
# or en if the language is not set.
|
||||
#epub_language = ''
|
||||
|
||||
# The scheme of the identifier. Typical schemes are ISBN or URL.
|
||||
#epub_scheme = ''
|
||||
|
||||
# The unique identifier of the text. This can be a ISBN number
|
||||
# or the project homepage.
|
||||
#epub_identifier = ''
|
||||
|
||||
# A unique identification for the text.
|
||||
#epub_uid = ''
|
||||
|
||||
# A tuple containing the cover image and cover page html template filenames.
|
||||
#epub_cover = ()
|
||||
|
||||
# A sequence of (type, uri, title) tuples for the guide element of content.opf.
|
||||
#epub_guide = ()
|
||||
|
||||
# HTML files that should be inserted before the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#epub_pre_files = []
|
||||
|
||||
# HTML files shat should be inserted after the pages created by sphinx.
|
||||
# The format is a list of tuples containing the path and title.
|
||||
#epub_post_files = []
|
||||
|
||||
# A list of files that should not be packed into the epub file.
|
||||
epub_exclude_files = ['search.html']
|
||||
|
||||
# The depth of the table of contents in toc.ncx.
|
||||
#epub_tocdepth = 3
|
||||
|
||||
# Allow duplicate toc entries.
|
||||
#epub_tocdup = True
|
||||
|
||||
# Choose between 'default' and 'includehidden'.
|
||||
#epub_tocscope = 'default'
|
||||
|
||||
# Fix unsupported image types using the PIL.
|
||||
#epub_fix_images = False
|
||||
|
||||
# Scale large images.
|
||||
#epub_max_image_width = 0
|
||||
|
||||
# How to display URL addresses: 'footnote', 'no', or 'inline'.
|
||||
#epub_show_urls = 'inline'
|
||||
|
||||
# If false, no index is generated.
|
||||
#epub_use_index = True
|
||||
|
||||
|
||||
|
||||
#-- Options for todo
|
||||
|
||||
todo_include_todos = True
|
||||
|
||||
#-- include template if not on RTD
|
||||
|
||||
if not on_rtd: # only import and set the theme if we're building docs locally
|
||||
import sphinx_rtd_theme
|
||||
html_theme = 'sphinx_rtd_theme'
|
||||
html_theme_path = [sphinx_rtd_theme.get_html_theme_path()]
|
||||
|
||||
# otherwise, readthedocs.org uses their theme by default, so no need to specify it
|
314
docs/source/development/access_control_model.rst
Normal file
@ -0,0 +1,314 @@
|
||||
.. Copyright (C) 2015 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Access controle model
|
||||
**********************
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
Concepts
|
||||
========
|
||||
|
||||
Every time an entity is created, viewed or updated, the software check if the user has the permission to make this action. The decision is made with three parameters :
|
||||
|
||||
- the type of entity ;
|
||||
- the entity's center ;
|
||||
- the entity'scope
|
||||
|
||||
The user must be granted access to the action on this particular entity, with this scope and center.
|
||||
|
||||
From an user point of view
|
||||
--------------------------
|
||||
|
||||
The software is design to allow fine tuned access rights for complicated installation and team structure. The administrators may also decide that every user has the right to see all resources, where team have a more simple structure.
|
||||
|
||||
Here is an overview of the model.
|
||||
|
||||
Chill can be multi-center
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Chill is designed to be installed once for social center who work with multiple teams separated, or for social services's federation who would like to share the same installation of the software for all their members.
|
||||
|
||||
This was required for cost reduction, but also to ease the generation of statistics agregated across federation's members, or from the central unit of the social center with multiple teams.
|
||||
|
||||
Otherwise, it is not required to create multiple center: Chill can also work for one center.
|
||||
|
||||
Obviously, users working in the different centers are not allowed to see the entities (_persons_, _reports_, _activities_) of other centers. But users may be attached to multiple centers: consequently they will be able to see the entities of the multiple centers they are attached to.
|
||||
|
||||
Inside center, scope divide team
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Users are attached to one or more center and, inside to those center, there may exists differents scopes. The aim of those _scopes_ is to divide the whole team of social worker amongst different departement, for instance: the social team, the psychologist team, the nurse team, the administrative team, ... Each team is granted of different rights amongst scope. For instance, the social team may not see the _activities_ of the psychologist team. The administrative team may see the date & time's activities, but is not allowed to see the detail of those entities (the personal notes, ...).
|
||||
|
||||
The administrator is responsible of creating those scopes and team. *He may also decide to not define a division inside his team*: he creates only one scope and all entities will belong to this scope, all users will be able to see all entities.
|
||||
|
||||
As entities have only one scopes, if some entities must be shared across two different teams, the administrator will have to create a scope *shared* by two different team, and add the ability to create, view, or update this scope to those team.
|
||||
|
||||
Example: if some activities must be seen and updated between nurses and psychologists, the administrator will create a scope "nurse and psy" and add the ability for both team "nurse" and "psychologist" to "create", "see", and "update" the activities belonging to scope "nurse and psy".
|
||||
|
||||
The concepts translated into code
|
||||
-----------------------------------
|
||||
|
||||
.. figure:: /_static/access_control_model.png
|
||||
|
||||
Schema of the access control model
|
||||
|
||||
Chill handle **entities**, like *persons*, *reports* (associated to *persons*), *activities* (also associated to *_persons*), ... On creation, those entities are linked to one center and, eventually, to one scope. They implements the interface `HasCenterInterface`.
|
||||
|
||||
.. note::
|
||||
|
||||
Somes entities are linked to a center through the entity they are associated with. For instance, *activities* or *reports* are associated to a *person*, and the person is associated to a *center*. The *report*'s *center* is always the *person*'s *center*.
|
||||
|
||||
Entities may be associated with a scope. In this case, they implement the `HasScopeInterface`.
|
||||
|
||||
.. note::
|
||||
|
||||
Currently, only the *person* entity is not associated with a scope.
|
||||
|
||||
At each step of his lifetime (creation, view of the entity and eventually of his details, update and, eventually, deletion), the right of the user are checked. To decide wether the user is granted right to execute the action, the software must decide with those elements :
|
||||
|
||||
- the entity's type;
|
||||
- the entity's center ;
|
||||
- the entity's scope, if it exists,
|
||||
- and, obviously, a string representing the action
|
||||
|
||||
All those action are executed through symfony voters and helpers.
|
||||
|
||||
How to check authorization ?
|
||||
----------------------------
|
||||
|
||||
Just use the symfony way-of-doing, but do not forget to associate the entity you want to check access. For instance, in controller :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
class MyController extends Controller
|
||||
{
|
||||
|
||||
public function viewAction($entity)
|
||||
{
|
||||
$this->denyAccessUnlessGranted('CHILL_ENTITY_SEE', $entity);
|
||||
|
||||
//... go on with this action
|
||||
}
|
||||
}
|
||||
|
||||
And in template :
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{{ if is_granted('CHILL_ENTITY_SEE', entity) %}print something{% endif %}
|
||||
|
||||
Retrieving reachable scopes and centers
|
||||
----------------------------------------
|
||||
|
||||
The class :class:`Chill\\MainBundle\\Security\\Authorization\\AuthorizationHelper` helps you to get centers and scope reachable by a user.
|
||||
|
||||
Those methods are intentionnaly build to give information about user rights:
|
||||
|
||||
- getReachableCenters: to get reachable centers for a user
|
||||
- getReachableScopes : to get reachable scopes for a user
|
||||
|
||||
.. note::
|
||||
|
||||
The service is reachable through the Depedency injection with the key `chill.main.security.authorization.helper`. Example :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$helper = $container->get('chill.main.security.authorization.helper');
|
||||
|
||||
.. todo::
|
||||
|
||||
Waiting for a link between our api and this doc, we invite you to read the method signatures `here <https://github.com/Chill-project/Main/blob/add_acl/Security/Authorization/AuthorizationHelper.php>`_
|
||||
|
||||
Adding your own roles
|
||||
=====================
|
||||
|
||||
Extending Chill will requires you to define your own roles and rules for your entities. You will have to define your own voter to do so.
|
||||
|
||||
To create your own roles, you should:
|
||||
|
||||
* implement your own voter. This voter will have to extends the :class:`Chill\\MainBundle\\Security\\AbstractChillVoter`. As defined by Symfony, this voter must be declared as a service and tagged with `security.voter`;
|
||||
* declare the role through implementing a service tagged with `chill.role` and implementing :class:`Chill\\MainBundle\\Security\\ProvideRoleInterface`.
|
||||
|
||||
.. note::
|
||||
|
||||
Both operation may be done through a simple class: you can implements :class:`Chill\\MainBundle\\Security\\ProvideRoleInterface` and :class:`Chill\\MainBundle\\Security\\AbstractChillVoter` on the same class. See live example: :class:`Chill\\ActivityBundle\\Security\\Authorization\\ActivityVoter`, and similar examples in the `PersonBundle` and `ReportBundle`.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`How to Use Voters to Check User Permissions <http://symfony.com/doc/current/cookbook/security/voters_data_permission.html>`_
|
||||
|
||||
From the symfony cookbook
|
||||
|
||||
`New in Symfony 2.6: Simpler Security Voters <http://symfony.com/blog/new-in-symfony-2-6-simpler-security-voters>`_
|
||||
|
||||
From the symfony blog
|
||||
|
||||
|
||||
Declare your role
|
||||
------------------
|
||||
|
||||
To declare new role, implement the class :class:`Chill\\MainBundle\\Security\\ProvideRoleInterface`.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
interface ProvideRoleInterface
|
||||
{
|
||||
/**
|
||||
* return an array of role provided by the object
|
||||
*
|
||||
* @return string[] array of roles (as string)
|
||||
*/
|
||||
public function getRoles();
|
||||
|
||||
/**
|
||||
* return roles which doesn't need
|
||||
*
|
||||
* @return string[] array of roles without scopes
|
||||
*/
|
||||
public function getRolesWithoutScope();
|
||||
}
|
||||
|
||||
|
||||
Then declare your service with a tag `chill.role`. Example :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
your_service:
|
||||
class: Chill\YourBundle\Security\Authorization\YourVoter
|
||||
tags:
|
||||
- { name: chill.role }
|
||||
|
||||
|
||||
Example of an implementation of :class:`Chill\\MainBundle\\Security\\ProvideRoleInterface`:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\Security\Authorization;
|
||||
|
||||
use Chill\MainBundle\Security\ProvideRoleInterface;
|
||||
|
||||
class PersonVoter implements ProvideRoleInterface
|
||||
{
|
||||
const CREATE = 'CHILL_PERSON_CREATE';
|
||||
const UPDATE = 'CHILL_PERSON_UPDATE';
|
||||
const SEE = 'CHILL_PERSON_SEE';
|
||||
|
||||
public function getRoles()
|
||||
{
|
||||
return array(self::CREATE, self::UPDATE, self::SEE);
|
||||
}
|
||||
|
||||
public function getRolesWithoutScope()
|
||||
{
|
||||
return array(self::CREATE, self::UPDATE, self::SEE);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
Implement your voter
|
||||
--------------------
|
||||
|
||||
Inside this class, you might use the :class:`Chill\\MainBundle\\Security\\Authorization\\AuthorizationHelper` to check permission (do not re-invent the wheel). This is a real-world example:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\ReportBundle\Security\Authorization;
|
||||
use Chill\MainBundle\Security\Authorization\AbstractChillVoter;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
|
||||
|
||||
class ReportVoter extends AbstractChillVoter
|
||||
{
|
||||
const CREATE = 'CHILL_REPORT_CREATE';
|
||||
const SEE = 'CHILL_REPORT_SEE';
|
||||
const UPDATE = 'CHILL_REPORT_UPDATE';
|
||||
|
||||
/**
|
||||
*
|
||||
* @var AuthorizationHelper
|
||||
*/
|
||||
protected $helper;
|
||||
|
||||
public function __construct(AuthorizationHelper $helper)
|
||||
{
|
||||
$this->helper = $helper;
|
||||
}
|
||||
|
||||
protected function getSupportedAttributes()
|
||||
{
|
||||
return array(self::CREATE, self::SEE, self::UPDATE);
|
||||
}
|
||||
protected function getSupportedClasses()
|
||||
{
|
||||
return array('Chill\ReportBundle\Entity\Report');
|
||||
}
|
||||
protected function isGranted($attribute, $report, $user = null)
|
||||
{
|
||||
if (! $user instanceof \Chill\MainBundle\Entity\User){
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
return $this->helper->userHasAccess($user, $report, $attribute);
|
||||
}
|
||||
}
|
||||
|
||||
Then, you will have to declare the service and tag it as a voter :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
services:
|
||||
chill.report.security.authorization.report_voter:
|
||||
class: Chill\ReportBundle\Security\Authorization\ReportVoter
|
||||
arguments:
|
||||
- "@chill.main.security.authorization.helper"
|
||||
tags:
|
||||
- { name: security.voter }
|
||||
|
||||
|
||||
Adding role hierarchy
|
||||
---------------------
|
||||
|
||||
You should prepend Symfony's security component directly from your code.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\ReportBundle\DependencyInjection;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Chill\MainBundle\DependencyInjection\MissingBundleException;
|
||||
|
||||
/**
|
||||
* This is the class that loads and manages your bundle configuration
|
||||
*
|
||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
||||
*/
|
||||
class ChillReportExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->prependRoleHierarchy($container);
|
||||
}
|
||||
|
||||
protected function prependRoleHierarchy(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('security', array(
|
||||
'role_hierarchy' => array(
|
||||
'CHILL_REPORT_UPDATE' => array('CHILL_REPORT_SEE'),
|
||||
'CHILL_REPORT_CREATE' => array('CHILL_REPORT_SEE')
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
104
docs/source/development/assets.rst
Normal file
@ -0,0 +1,104 @@
|
||||
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _forms:
|
||||
|
||||
Assets
|
||||
#######
|
||||
|
||||
The Chill assets (js, css, images, …) can be managed by `Webpack Encore`_, which is a thin wrapper for `Webpack`_ in Symfony applications.
|
||||
|
||||
Installation
|
||||
************
|
||||
|
||||
Webpack Encore needs to be run in a Node.js environment, using the Yarn package manager. This Node.js environment can be set up using a node docker image. The bash script `docker-node.sh` set up a Node.js environment with an adequate configuration. Launch this container by typing:
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ bash docker-node.sh
|
||||
|
||||
In this NodeJS environment, install all the assets required by Chill with:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
node@b91cab4f7cfc:/app$ yarn install
|
||||
|
||||
This command will install all the packages that are listed in `package.json`.
|
||||
|
||||
Any further required dependencies can be installed using the Yarn package. For instance, jQuery is installed by:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
node@b91cab4f7cfc:/app$ yarn add jquery --dev
|
||||
|
||||
|
||||
Usage
|
||||
*****
|
||||
|
||||
Organize your assets
|
||||
--------------------
|
||||
|
||||
Chill assets usually lives under the `/Resources/public` folder of each Chill bundle. The Webpack configuration set up in `webpack.config.js` automatically loads the required assets from the Chill bundles that are used.
|
||||
|
||||
For adding your own assets to Webpack, you must add an entry in the `webpack.config.js` file. For instance, the following entry will output a file `main.js` collecting the js code (and possibly css, image, etc.) from `./assets/main.js`.
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
.addEntry('main', './assets/main.js')
|
||||
|
||||
To gather the css files, simply connect them to your js file, using `require`. The css file is seen as a dependency of your js file. :
|
||||
|
||||
.. code-block:: js
|
||||
|
||||
// assets/js/main.js
|
||||
require('../css/app.css');
|
||||
|
||||
For finer configuration of webpack encore, we refer to the above-linked documentation.
|
||||
|
||||
|
||||
Compile the assets
|
||||
------------------
|
||||
|
||||
To compile the assets, run this line in the NodeJS container:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
node@b91cab4f7cfc:/app$ yarn run encore dev
|
||||
|
||||
While developing, you can tell Webpack Encore to continuously watch the files you are modifying:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
node@b91cab4f7cfc:/app$ yarn run encore dev --watch
|
||||
|
||||
|
||||
Use the assets in the templates
|
||||
--------------------------------
|
||||
|
||||
Any entry defined in the webpack.config.js file can be linked to your application using the symfony `asset` helper:
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<head>
|
||||
...
|
||||
<link rel="stylesheet" href="{{ asset('build/app.css') }}">
|
||||
</head>
|
||||
<body>
|
||||
...
|
||||
<script src="{{ asset('build/app.js') }}"></script>
|
||||
</body>
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.. _Webpack Encore: https://www.npmjs.com/package/@symfony/webpack-encore
|
||||
.. _Webpack: https://webpack.js.org/
|
34
docs/source/development/create-a-new-bundle.rst
Normal file
@ -0,0 +1,34 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _create-new-bundle:
|
||||
|
||||
Create a new bundle
|
||||
*******************
|
||||
|
||||
Create your own bundle is not a trivial task.
|
||||
|
||||
The easiest way to achieve this is seems to be :
|
||||
|
||||
1. Prepare a fresh installation of the chill project, in a new directory
|
||||
2. Create a new bundle in this project, in the src directory
|
||||
3. Initialize a git repository **at the root bundle**, and create your initial commit.
|
||||
4. Register the bundle with composer/packagist. If you do not plan to distribute your bundle with packagist, you may use a custom repository for achieve this [#f1]_
|
||||
5. Move to a development installation, made as described in the :ref:`installation-for-development` section, and add your new repository to the composer.json file
|
||||
6. Work as :ref:`usual <editing-code-and-commiting>`
|
||||
|
||||
.. warning::
|
||||
|
||||
This part of the doc is not yet tested
|
||||
|
||||
TODO
|
||||
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
.. [#f1] Be aware that we use the Affero GPL Licence, which ensure that all users must have access to derivative works done with this software.
|
522
docs/source/development/crud.rst
Normal file
@ -0,0 +1,522 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _crud:
|
||||
|
||||
CRUD
|
||||
####
|
||||
|
||||
Chill provide an API to create a basic CRUD.
|
||||
|
||||
One can follow those steps to create a CRUD for one entity:
|
||||
|
||||
1. create your model and your form ;
|
||||
2. configure the crud ;
|
||||
3. customize the templates if required ;
|
||||
4. customize some steps of the controller if required ;
|
||||
|
||||
|
||||
An example with the ``ClosingMotive`` (PersonBundle) in the admin part of Chill:
|
||||
|
||||
Auto-loading the routes
|
||||
***********************
|
||||
|
||||
Ensure that those lines are present in your file `app/config/routing.yml`:
|
||||
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_cruds:
|
||||
resource: 'chill_main_crud_route_loader:load'
|
||||
type: service
|
||||
|
||||
|
||||
|
||||
Create your model
|
||||
*****************
|
||||
|
||||
Create your model on the usual way (in this example, ORM informations are stored in yaml file):
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\Entity\AccompanyingPeriod;
|
||||
|
||||
use Doctrine\Common\Collections\Collection;
|
||||
|
||||
/**
|
||||
* ClosingMotive give an explanation why we closed the Accompanying period
|
||||
*/
|
||||
class ClosingMotive
|
||||
{
|
||||
/**
|
||||
* @var integer
|
||||
*/
|
||||
private $id;
|
||||
|
||||
/**
|
||||
* @var array
|
||||
*/
|
||||
private $name;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var boolean
|
||||
*/
|
||||
private $active = true;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var self
|
||||
*/
|
||||
private $parent = null;
|
||||
|
||||
/**
|
||||
* child Accompanying periods
|
||||
*
|
||||
* @var Collection
|
||||
*/
|
||||
private $children;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var float
|
||||
*/
|
||||
private $ordering = 0.0;
|
||||
|
||||
|
||||
// getters and setters come here
|
||||
|
||||
}
|
||||
|
||||
The form:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\Form;
|
||||
|
||||
use Symfony\Component\Form\AbstractType;
|
||||
use Symfony\Component\Form\FormBuilderInterface;
|
||||
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||||
use Chill\PersonBundle\Form\Type\ClosingMotivePickerType;
|
||||
use Chill\MainBundle\Form\Type\TranslatableStringFormType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||||
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||||
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
class ClosingMotiveType extends AbstractType
|
||||
{
|
||||
public function buildForm(FormBuilderInterface $builder, array $options)
|
||||
{
|
||||
$builder
|
||||
->add('name', TranslatableStringFormType::class, [
|
||||
'label' => 'Nom'
|
||||
])
|
||||
->add('active', CheckboxType::class, [
|
||||
'label' => 'Actif ?',
|
||||
'required' => false
|
||||
])
|
||||
->add('ordering', NumberType::class, [
|
||||
'label' => 'Ordre d\'apparition',
|
||||
'required' => true,
|
||||
'scale' => 5
|
||||
])
|
||||
->add('parent', ClosingMotivePickerType::class, [
|
||||
'label' => 'Parent',
|
||||
'required' => false,
|
||||
'placeholder' => 'closing_motive.any parent',
|
||||
'multiple' => false,
|
||||
'only_leaf' => false
|
||||
])
|
||||
;
|
||||
}
|
||||
|
||||
public function configureOptions(OptionsResolver $resolver)
|
||||
{
|
||||
$resolver
|
||||
->setDefault('class', \Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive::class)
|
||||
;
|
||||
}
|
||||
}
|
||||
|
||||
Configure the crud
|
||||
******************
|
||||
|
||||
The crud is configured using the key ``crud`` under ``chill_main``
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_main:
|
||||
cruds:
|
||||
-
|
||||
# the class which is concerned by the CRUD
|
||||
class: '\Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive::class'
|
||||
# give a name for the crud. This will be used internally
|
||||
name: closing_motive
|
||||
# add a base path for the
|
||||
base_path: /admin/closing-motive
|
||||
# this is the form class
|
||||
form_class: 'Chill\PersonBundle\Form\ClosingMotiveType::class'
|
||||
# you can override the controller to configure some parts
|
||||
# if you do not configure anything here, the default CRUDController will be used
|
||||
controller: 'Chill\PersonBundle\Controller\AdminClosingMotiveController::class'
|
||||
# this is a list of action you can configure
|
||||
# by default, the actions `index`, `view`, `new` and `edit` are automatically create
|
||||
# you can add more actions or configure some details about them
|
||||
actions:
|
||||
index:
|
||||
# the default template for index is very poor,
|
||||
# you will need to override it
|
||||
template: '@ChillPerson/ClosingMotive/index.html.twig'
|
||||
# the role required for this role
|
||||
role: ROLE_ADMIN
|
||||
new:
|
||||
role: ROLE_ADMIN
|
||||
# by default, the template will only show the form
|
||||
# you can override it
|
||||
template: '@ChillPerson/ClosingMotive/new.html.twig'
|
||||
edit:
|
||||
role: ROLE_ADMIN
|
||||
template: '@ChillPerson/ClosingMotive/edit.html.twig'
|
||||
|
||||
To leave the bundle auto-configure the ``chill_main`` bundle, you can `prepend the configuration of the ChillMain Bundle <https://symfony.com/doc/current/bundles/prepend_extension.html>`_:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
|
||||
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
// skipped here
|
||||
}
|
||||
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->prependCruds($container);
|
||||
}
|
||||
|
||||
protected function prependCruds(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', [
|
||||
'cruds' => [
|
||||
[
|
||||
'class' => \Chill\PersonBundle\Entity\AccompanyingPeriod\ClosingMotive::class,
|
||||
'name' => 'closing_motive',
|
||||
'base_path' => '/admin/closing-motive',
|
||||
'form_class' => \Chill\PersonBundle\Form\ClosingMotiveType::class,
|
||||
'controller' => \Chill\PersonBundle\Controller\AdminClosingMotiveController::class,
|
||||
'actions' => [
|
||||
'index' => [
|
||||
'template' => '@ChillPerson/ClosingMotive/index.html.twig',
|
||||
'role' => 'ROLE_ADMIN'
|
||||
],
|
||||
'new' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/ClosingMotive/new.html.twig',
|
||||
],
|
||||
'edit' => [
|
||||
'role' => 'ROLE_ADMIN',
|
||||
'template' => '@ChillPerson/ClosingMotive/edit.html.twig',
|
||||
]
|
||||
]
|
||||
]
|
||||
]
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
Customize templates
|
||||
*******************
|
||||
|
||||
The current template are quite basic. You can override and extends them.
|
||||
|
||||
For a better inclusion, you can embed them instead of extending them.
|
||||
|
||||
For index. Note that we extend here the `admin` layout, not the default one:
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_index.html.twig' %}
|
||||
{# we customize the table headers #}
|
||||
{% block table_entities_thead_tr %}
|
||||
<th>{{ 'Ordering'|trans }}</th>
|
||||
<th>{{ 'Label'|trans }}</th>
|
||||
<th>{{ 'Active'|trans }}</th>
|
||||
<th> </th>
|
||||
{% endblock %}
|
||||
|
||||
{% block table_entities_tbody %}
|
||||
{# we customize the content of the table #}
|
||||
{% for entity in entities %}
|
||||
<tr>
|
||||
<td>{{ entity.ordering }}</td>
|
||||
<td>{{ entity|chill_entity_render_box }}</td>
|
||||
<td>{{ entity.active }}</td>
|
||||
<td>
|
||||
<ul class="record_actions">
|
||||
<li>
|
||||
<a href="{{ chill_path_add_return_path('chill_crud_closing_motive_edit', { 'id': entity.id }) }}" class="sc-button bt-edit"></a>
|
||||
</li>
|
||||
<li>
|
||||
<a href="{{ chill_path_add_return_path('chill_crud_closing_motive_new', { 'parent_id': entity.id } ) }}" class="sc-button bt-new">{{ 'closing_motive.new child'|trans }}</a>
|
||||
</li>
|
||||
</ul>
|
||||
</td>
|
||||
</tr>
|
||||
{% endfor %}
|
||||
{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
For edit template:
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_edit_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% as we are in the admin layout, we override the admin content with the CRUD content %}
|
||||
{% embed '@ChillMain/CRUD/_edit_content.html.twig' %}
|
||||
{# we do not have "view" page. We empty the corresponding block #}
|
||||
{% block content_form_actions_view %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
For new template:
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{% extends '@ChillMain/Admin/layout.html.twig' %}
|
||||
|
||||
{% block title %}
|
||||
{% include('@ChillMain/CRUD/_new_title.html.twig') %}
|
||||
{% endblock %}
|
||||
|
||||
{% block admin_content %}
|
||||
{% embed '@ChillMain/CRUD/_new_content.html.twig' %}
|
||||
{% block content_form_actions_save_and_show %}{% endblock %}
|
||||
{% endembed %}
|
||||
{% endblock %}
|
||||
|
||||
Customize some steps in the controller
|
||||
**************************************
|
||||
|
||||
Some steps may be customized by overriding the default controller and some methods. Here, we will override the way the entity is created, and the ordering of the "index" page:
|
||||
|
||||
* we will associate a parent ClosingMotive to the element if a parameter `parent_id` is found ;
|
||||
* we will order the ClosingMotive by the ``ordering`` property
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Chill\MainBundle\CRUD\Controller\CRUDController;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Chill\MainBundle\Pagination\PaginatorInterface;
|
||||
|
||||
/**
|
||||
* Controller for closing motives
|
||||
*
|
||||
*/
|
||||
class AdminClosingMotiveController extends CRUDController
|
||||
{
|
||||
protected function createEntity($action, Request $request): object
|
||||
{
|
||||
// we first create an entity "the usual way"
|
||||
$entity = parent::createEntity($action, $request);
|
||||
|
||||
if ($request->query->has('parent_id')) {
|
||||
// if we find the parent_id parameter, we add the corresponding
|
||||
// parent to the newly created entity
|
||||
$parentId = $request->query->getInt('parent_id');
|
||||
|
||||
$parent = $this->getDoctrine()->getManager()
|
||||
->getRepository($this->getEntityClass())
|
||||
->find($parentId);
|
||||
|
||||
if (NULL === $parent) {
|
||||
throw $this->createNotFoundException('parent id not found');
|
||||
}
|
||||
|
||||
$entity->setParent($parent);
|
||||
}
|
||||
|
||||
return $entity;
|
||||
}
|
||||
|
||||
protected function orderQuery(string $action, $query, Request $request, PaginatorInterface $paginator)
|
||||
{
|
||||
// by default, the query is an instance of QueryBuilder
|
||||
/** @var \Doctrine\ORM\QueryBuilder $query */
|
||||
return $query->orderBy('e.ordering', 'ASC');
|
||||
}
|
||||
}
|
||||
|
||||
How-to and questions
|
||||
********************
|
||||
|
||||
Which role is required for each action ?
|
||||
========================================
|
||||
|
||||
By default, each action will use:
|
||||
|
||||
1. the role defined under the action key ;
|
||||
2. the base role as upper, with the action name appended:
|
||||
|
||||
Example: if the base role is ``CHILL_BUNDLE_ENTITY``, the role will become:
|
||||
|
||||
* ``CHILL_BUNDLE_ENTITY_VIEW`` for the ``view`` action ;
|
||||
* ``CHILL_BUNDLE_ENTITY_INDEX`` for the ``index`` action.
|
||||
|
||||
The entity will be passed to the role:
|
||||
|
||||
* for the ``view`` and ``edit`` action: the entity fetched from database
|
||||
* for the ``new`` action: the entity which is created (you can override default values using
|
||||
* for index action (or if you re-use the ``indexAction`` method: ``null``
|
||||
|
||||
How to add some route and actions ?
|
||||
===================================
|
||||
|
||||
Add them under the action key:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_main:
|
||||
cruds:
|
||||
-
|
||||
# snipped
|
||||
actions:
|
||||
myaction: ~
|
||||
|
||||
The method `myactionAction` will be called by the parameter.
|
||||
|
||||
Inside this action, you can eventually call another internal method:
|
||||
|
||||
* ``indexAction`` for a list of items ;
|
||||
* ``viewAction`` for a view
|
||||
* ``editFormAction`` for an edition
|
||||
* ``createFormAction`` for a creation
|
||||
|
||||
Example:
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace CSConnectes\SPBundle\Controller;
|
||||
|
||||
use Chill\PersonBundle\CRUD\Controller\OneToOneEntityPersonCRUDController;
|
||||
use Sensio\Bundle\FrameworkExtraBundle\Configuration\Route;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\Form\FormInterface;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use CSConnectes\SPBundle\Form\CSPersonPersonalSituationType;
|
||||
use CSConnectes\SPBundle\Form\CSPersonDispositifsType;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
|
||||
class CSPersonController extends OneToOneEntityPersonCRUDController
|
||||
{
|
||||
public function personalSituationEdit(Request $request, $id)
|
||||
{
|
||||
return $this->formEditAction(
|
||||
'ps_situation_edit',
|
||||
$request,
|
||||
$id,
|
||||
CSPersonPersonalSituationType::class
|
||||
);
|
||||
}
|
||||
|
||||
public function personalSituationView(Request $request, $id): Response
|
||||
{
|
||||
return $this->viewAction('ps_situation_view', $request, $id);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
How to create a CRUD for entities associated to persons
|
||||
=======================================================
|
||||
|
||||
The bundle person provide some controller and template you can override, instead of the ones present in the mainbundle:
|
||||
|
||||
* :code:`Chill\PersonBundle\CRUD\Controller\EntityPersonCRUDController` for entities linked with a one-to-may association to :code:`Person` class ;
|
||||
* :code:`Chill\PersonBundle\CRUD\Controller\OneToOneEntityPersonCRUDController` for entities linked with a one-to-one association to :code:`Person` class.
|
||||
|
||||
There are also template defined under ``@ChillPerson/CRUD/`` namespace.
|
||||
|
||||
Those controller assume that:
|
||||
|
||||
* the entity provide the method :code:`getPerson` and :code:`setPerson` ;
|
||||
* the `index`'s id path will be the id of the person, and the ids in `view` and `edit` path will be the id of the entity ;
|
||||
|
||||
This bundle also use by default the templates inside ``@ChillPerson/CRUD/``.
|
||||
|
||||
|
||||
Reference
|
||||
*********
|
||||
|
||||
Configuration reference
|
||||
=======================
|
||||
|
||||
|
||||
.. code-block:: txt
|
||||
|
||||
chill_main:
|
||||
cruds:
|
||||
|
||||
# Prototype
|
||||
-
|
||||
class: ~ # Required
|
||||
controller: Chill\MainBundle\CRUD\Controller\CRUDController
|
||||
name: ~ # Required
|
||||
base_path: ~ # Required
|
||||
base_role: null
|
||||
form_class: null
|
||||
actions:
|
||||
|
||||
# Prototype
|
||||
name:
|
||||
|
||||
# the method name to call in the route. Will be set to the action name if left empty.
|
||||
controller_action: null # Example: 'action'
|
||||
|
||||
# the path that will be **appended** after the base path. Do not forget to add arguments for the method. Will be set to the action name, including an `{id}` parameter if left empty.
|
||||
path: null # Example: /{id}/my-action
|
||||
|
||||
# the requirements for the route. Will be set to `[ 'id' => '\d+' ]` if left empty.
|
||||
requirements: []
|
||||
|
||||
# the role that will be required for this action. Override option `base_role`
|
||||
role: null
|
||||
|
||||
# the template to render the view
|
||||
template: null
|
||||
|
||||
Twig default block
|
||||
==================
|
||||
|
||||
This part should be documented.
|
||||
|
244
docs/source/development/exports.rst
Normal file
@ -0,0 +1,244 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
Exports
|
||||
*******
|
||||
|
||||
Export is an important issue for the Chill software : users should be able to :
|
||||
|
||||
- compute statistics about their activity ;
|
||||
- list "things" which make part of their activities.
|
||||
|
||||
The `main bundle`_ provides a powerful framework to build custom queries with re-usable parts across differents bundles.
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
.. seealso::
|
||||
|
||||
`The issue where this framework was discussed <https://git.framasoft.org/Chill-project/Chill-Main/issues/9>`_
|
||||
Provides some information about the pursued features and architecture.
|
||||
|
||||
Concepts
|
||||
========
|
||||
|
||||
|
||||
Some vocabulary: 3 "Export elements"
|
||||
------------------------------------
|
||||
|
||||
Four terms are used for this framework :
|
||||
|
||||
exports
|
||||
provides some basic operation on the date. Two kind of exports are available :
|
||||
|
||||
- computed data : it may be "the number of people", "the number of activities", "the duration of activities", ...
|
||||
- list data : it may be "the list of people", "the list of activity", ...
|
||||
|
||||
filters
|
||||
The filters make a filter on the date: it removes some information the user doesn't want to introduce in the computation done by export. In other word, filters make a filter...
|
||||
|
||||
Example of filter: "people under 18 years olds", "activities between the 1st of June and the 31st December", ...
|
||||
|
||||
aggregators
|
||||
The aggregator aggregates the data into some group (some software use the term 'bucket').
|
||||
|
||||
Example of aggregator : "group people by gender", "group people by nationality", "group activity by type", ...
|
||||
|
||||
formatters
|
||||
The formatters format the data into a :class:`Symfony\Component\HttpFoundation\Response`, which will be returned "as is" by the controller to the web client.
|
||||
|
||||
Example of formatter: "format data as CSV", "format data as ods spreadsheet", ...
|
||||
|
||||
Anatomy of an export
|
||||
---------------------
|
||||
|
||||
An export may be explained as a sentence, where each part of this sentence refers to one or multiple exports element. Examples :
|
||||
|
||||
**Example 1**: Count the number of people having at least one activity in the last 12 month, and group them by nationality and gender, and format them in a CSV spreadsheet.
|
||||
|
||||
Here :
|
||||
|
||||
- *count the number of people* is the export part
|
||||
- *having at least one activity* is the filter part
|
||||
- *group them by nationality* is the aggregator part
|
||||
- *group them by gender* is a second aggregator part
|
||||
- *format the date in a CSV spreadsheet* is the formatter part
|
||||
|
||||
Note that :
|
||||
|
||||
- aggregators, filters, exports and aggregators are cross-bundle. Here the bundle *activity* provides a filter which apply on an export provided by the person bundle ;
|
||||
- there may exists multiple aggregator or filter for one export. Currently, only one export is allowed.
|
||||
|
||||
The result might be :
|
||||
|
||||
+-----------------------+----------------+---------------------------+
|
||||
| Nationality | Gender | Number of people |
|
||||
+=======================+================+===========================+
|
||||
| Russian | Male | 12 |
|
||||
+-----------------------+----------------+---------------------------+
|
||||
| Russian | Female | 24 |
|
||||
+-----------------------+----------------+---------------------------+
|
||||
| France | Male | 110 |
|
||||
+-----------------------+----------------+---------------------------+
|
||||
| France | Female | 150 |
|
||||
+-----------------------+----------------+---------------------------+
|
||||
|
||||
**Example 2**: Count the average duration of an activity with type "meeting", which occurs between the 1st of June and the 31st of December, group them by week, and format the data in a OpenDocument spreadsheet.
|
||||
|
||||
Here :
|
||||
|
||||
- *count the average duration of an activity* is the export part
|
||||
- *activity with type meeting* is a filter part
|
||||
- *activity which occurs between the 1st of June and the 31st of December* is a filter
|
||||
- *group them by week* is the aggregator part
|
||||
- *format the date in an OpenDocument spreadsheet* is the formatter part
|
||||
|
||||
The result might be :
|
||||
|
||||
+-----------------------+----------------------+
|
||||
| Week | Number of activities |
|
||||
+=======================+======================+
|
||||
| 2015-10 | 10 |
|
||||
+-----------------------+----------------------+
|
||||
| 2015-11 | 12 |
|
||||
+-----------------------+----------------------+
|
||||
| 2015-12 | 10 |
|
||||
+-----------------------+----------------------+
|
||||
| 2015-13 | 9 |
|
||||
+-----------------------+----------------------+
|
||||
|
||||
Authorization and exports
|
||||
-------------------------
|
||||
|
||||
Exports, filters and aggregators should not make see data the user is not allowed to see.
|
||||
|
||||
In other words, developers are required to take care of user authorization for each export.
|
||||
|
||||
It should exists a special role that should be granted to users which are allowed to build exports. For more simplicity, this role should apply on center, and should not requires special circles.
|
||||
|
||||
How does the magic works ?
|
||||
===========================
|
||||
|
||||
To build an export, we rely on the capacity of the database to execute queries with aggregate (i.e. GROUP BY) and filter (i.e. WHERE) instructions.
|
||||
|
||||
An export is an SQL query which is initiated by an export, and modified by aggregators and filters.
|
||||
|
||||
.. note::
|
||||
|
||||
**Example**: Count the number of people having at least one activity in the last 12 month, and group them by nationality and gender
|
||||
|
||||
1. The report initiate the query
|
||||
|
||||
.. code-block:: SQL
|
||||
|
||||
SELECT count(people.*) FROM people
|
||||
|
||||
2. The filter add a where and join clause :
|
||||
|
||||
.. code-block:: SQL
|
||||
|
||||
SELECT count(people.*) FROM people
|
||||
RIGHT JOIN activity
|
||||
WHERE activity.date IS BETWEEN now AND 6 month ago
|
||||
|
||||
3. The aggregator "nationality" add a GROUP BY clause and a column in the SELECT statement:
|
||||
|
||||
.. code-block:: sql
|
||||
|
||||
SELECT people.nationality, count(people.*) FROM people
|
||||
RIGHT JOIN activity
|
||||
WHERE activity.date IS BETWEEN now AND 6 month ago
|
||||
GROUP BY nationality
|
||||
|
||||
4. The aggregator "gender" do the same job as the nationality aggregator : it adds a GROUP BY clause and a column in the SELECT statement :
|
||||
|
||||
.. code-block:: sql
|
||||
|
||||
SELECT people.nationality, people.gender, count(people.*)
|
||||
FROM people RIGHT JOIN activity
|
||||
WHERE activity.date IS BETWEEN now AND 6 month ago
|
||||
GROUP BY nationality, gender
|
||||
|
||||
Each filter, aggregator and filter may collect parameters from the user by providing a form. This form is appended to the export form. Here is an example.
|
||||
|
||||
.. figure:: /_static/screenshots/development/export_form-fullpage.png
|
||||
|
||||
The screenshot show the export form for ``CountPeople`` (Nombre de personnes). The filter by date of birth is checked (*Filtrer par date de naissance de la personne*), which allow to show a subform, which is provided by the :class:`Chill\PersonBundle\Export\Filter\BirthdateFilter`. The other filter, which are unchecked, does not show the subform.
|
||||
|
||||
Two aggregators are also checked : by Country of birth (*Aggréger les personnes par pays de naissance*, corresponding class is :class:`Chill\PersonBundle\Export\Aggregator\CountryOfBirthAggregator`, which also open a subform. The aggregator by gender (*Aggréger les personnes par genre*) is also checked, but there is no corresponding subform.
|
||||
|
||||
The Export Manager
|
||||
------------------
|
||||
|
||||
The Export manager (:class:`Chill\MainBundle\Export\ExportManager` is the central class which register all exports, aggregators, filters and formatters.
|
||||
|
||||
The export manager is also responsible for orchestrating the whole export process, producing a :class:`Symfony\FrameworkBundle\HttpFoundation\Request` to each export request.
|
||||
|
||||
|
||||
The export form step
|
||||
--------------------
|
||||
|
||||
The form step allow to build a form, aggregating different parts of the module.
|
||||
|
||||
The building of forms is separated between different subform, which are responsible for rendering their part of the form (aggregators, filters, and export).
|
||||
|
||||
.. figure:: /_static/puml/exports/form_steps.png
|
||||
:scale: 40%
|
||||
|
||||
The formatter form step
|
||||
-----------------------
|
||||
|
||||
The formatter form is processed *after* the user filled the export form. It is built the same way, but receive in parameters the data entered by the user on the previous step (i.e. export form). It may then adapt it accordingly (example: show a list of columns selected in aggregators).
|
||||
|
||||
Processing the export
|
||||
---------------------
|
||||
|
||||
The export process may be explained by this schema :
|
||||
|
||||
.. figure:: /_static/puml/exports/processing_export.png
|
||||
:scale: 40%
|
||||
|
||||
(Click to enlarge)
|
||||
|
||||
|
||||
Export, formatters and filters explained
|
||||
========================================
|
||||
|
||||
Exports
|
||||
-------
|
||||
|
||||
This is an example of the ``CountPerson`` export :
|
||||
|
||||
.. literalinclude:: /_static/code/exports/CountPerson.php
|
||||
:language: php
|
||||
:linenos:
|
||||
|
||||
* **Line 36**: the ``getType`` function return a string. This string will be used to find the aggregtors and filters which will apply to this export.
|
||||
* **Line 41**: a simple description to help user to understand what your export does.
|
||||
* **Line 46**: The title of the export. A summary of what your export does.
|
||||
* **Line 51**: The list of roles requires to execute this export.
|
||||
* **Line 56**: We initiate the query here...
|
||||
* **Line 59**: We have to filter the query with centers the users checked in the form. We process the $acl variable to get all ``Center`` object in one array
|
||||
* **Line 63**: We create the query, with a query builder.
|
||||
* **Line 74**: We simply returns the result, but take care of hydrating the results as an array.
|
||||
* **Line 103**: return the list of formatters types which are allowed to apply on this filter
|
||||
|
||||
Filters
|
||||
-------
|
||||
|
||||
This is an example of the *filter by birthdate*. This filter ask some information in a form (`buildForm` is not empty), and this form must be validated. To performs this validations, we implement a new Interface: :class:`Chill\MainBundle\Export\ExportElementValidatedInterface`:
|
||||
|
||||
.. literalinclude:: /_static/code/exports/BirthdateFilter.php
|
||||
:language: php
|
||||
|
||||
.. todo::
|
||||
|
||||
Continue to explain the export framework
|
||||
|
||||
.. _main bundle: https://git.framasoft.org/Chill-project/Chill-Main
|
42
docs/source/development/forms.rst
Normal file
@ -0,0 +1,42 @@
|
||||
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _forms:
|
||||
|
||||
Forms and form types
|
||||
####################
|
||||
|
||||
Date picker
|
||||
***********
|
||||
|
||||
Class
|
||||
:class:`Chill\MainBundle\Form\Type\ChillDateType`
|
||||
Extend
|
||||
:class:`Symfony\Component\Form\Extension\Core\Type\DateType`
|
||||
|
||||
|
||||
Usage :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use Chill\MainBundle\Form\Type\ChillDateType;
|
||||
|
||||
$builder->add('date' ChillDateType::class);
|
||||
|
||||
Text editor
|
||||
***********
|
||||
|
||||
Add a text editor (by default).
|
||||
|
||||
Class
|
||||
:class:`Chill\MainBundle\Form\Type\ChillTextareaType`
|
||||
Options
|
||||
* :code:`disable_editor` to disable text editor
|
||||
|
||||
|
52
docs/source/development/index.rst
Normal file
@ -0,0 +1,52 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Development
|
||||
###########
|
||||
|
||||
As Chill rely on the `symfony <http://symfony.com>`_ framework, reading the framework's documentation should answer most of your questions. We are explaining here some tips to work with Chill, and things we provide to encounter our needs.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
Install Chill for development <installation.rst>
|
||||
Instructions to create a new bundle <create-a-new-bundle.rst>
|
||||
CRUD (Create - Update - Delete) for one entity <crud.rst>
|
||||
Routing <routing.rst>
|
||||
Menus <menus.rst>
|
||||
Forms <forms.rst>
|
||||
Access control model <access_control_model.rst>
|
||||
Messages to users <messages-to-users.rst>
|
||||
Pagination <pagination.rst>
|
||||
Localisation <localisation.rst>
|
||||
Logging <logging.rst>
|
||||
Database migrations <migrations.rst>
|
||||
Searching <searching.rst>
|
||||
Timelines <timelines.rst>
|
||||
Exports <exports.rst>
|
||||
Testing <make-test-working.rst>
|
||||
Useful snippets <useful-snippets.rst>
|
||||
manual/index.rst
|
||||
Assets <assets.rst>
|
||||
|
||||
Layout and UI
|
||||
**************
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
Layout / Template usage <user-interface/layout-template-usage.rst>
|
||||
Classes and mixins <user-interface/css-classes.rst>
|
||||
Widgets <user-interface/widgets.rst>
|
||||
Javascript function <user-interface/js-functions.rst>
|
||||
|
||||
|
||||
Help, I am lost !
|
||||
*****************
|
||||
|
||||
Write an email at info@champs-libres.coop, and we will help you !
|
155
docs/source/development/installation.rst
Normal file
@ -0,0 +1,155 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _installation-for-development :
|
||||
|
||||
Installation for development
|
||||
****************************
|
||||
|
||||
Installation for development should allow:
|
||||
|
||||
- access to the source code,
|
||||
- upload the code to our CVS (i.e. `git`_) and
|
||||
- work with `composer`_.
|
||||
|
||||
As Chill is divided into bundles (the Symfony name for 'modules'), each bundle has his own repository.
|
||||
|
||||
Installation and big picture
|
||||
----------------------------
|
||||
|
||||
First, you should install Chill as described in the :ref:`basic-installation` section.
|
||||
|
||||
Two things must be modified :
|
||||
|
||||
First, add the `--prefer-source` argument when you create project.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
composer create-project chill-project/standard path/to/your/directory --stability=dev --prefer-source
|
||||
|
||||
Second, when composer ask you the following question : ::
|
||||
|
||||
Do you want to remove the existing VCS (.git, .svn..) history? [Y,n]?
|
||||
|
||||
**You should answer `n` (no).**
|
||||
|
||||
Once Chill is installed, all the downloaded bundles will be stored in the `/vendor` directories.
|
||||
In those directories, you will have access to the git commands.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ cd vendor/chill-project/main/
|
||||
$ git remote -v
|
||||
composer git://github.com/Chill-project/Standard.git (fetch)
|
||||
composer git://github.com/Chill-project/Standard.git (push)
|
||||
origin git://github.com/Chill-project/Standard.git (fetch)
|
||||
origin git@github.com:Chill-project/Standard.git (push)
|
||||
|
||||
Files cleaning after installation
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Composer will delete unrequired files, and add some. This is perfectly normal and will appears in your git index.
|
||||
But you should NOT delete those files.
|
||||
|
||||
This is the expected 'git status' result:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$git status
|
||||
#(...)
|
||||
|
||||
Modifications qui ne seront pas validées :
|
||||
(utilisez "git add/rm <fichier>..." pour mettre à jour ce qui sera validé)
|
||||
(utilisez "git checkout -- <fichier>..." pour annuler les modifications dans la copie de travail)
|
||||
|
||||
modifié: app/SymfonyRequirements.php
|
||||
supprimé: app/SymfonyStandard/Composer.php
|
||||
supprimé: app/SymfonyStandard/RootPackageInstallSubscriber.php
|
||||
modifié: app/check.php
|
||||
|
||||
You can ignore the local changes using the `git update-index --assume-unchanged` command.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ git update-index --assume-unchanged app/check.php
|
||||
$ git update-index --assume-unchanged app/SymfonyRequirements.php
|
||||
$ git update-index --assume-unchanged app/SymfonyStandard/Composer.php
|
||||
$ git update-index --assume-unchanged app/SymfonyStandard/RootPackageInstallSuscriber.php
|
||||
|
||||
Working with your own fork
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Ideally, you will work on a fork of the main github repository.
|
||||
To ensure that composer will download the code from **your** repository, you will have to adapt the `composer.json` file accordingly, using your own repositories.
|
||||
|
||||
For each Chill module that you have forked, add an indexed array into the "repositories" key of the composer.json file
|
||||
at the root of the chill installation directory if you want to force composer to download from your own forked repositories:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
"repositories": [
|
||||
{
|
||||
"type": "git",
|
||||
"url": "git://github.com/your-github-username/ChillMain.git"
|
||||
},
|
||||
{
|
||||
"type": "git",
|
||||
"url": "git://github.com/your-github-username/Chill-Person.git"
|
||||
}
|
||||
]
|
||||
|
||||
|
||||
Then run composer update to load your forked code.
|
||||
If it does not happen, delete the content of the chill/vendor/chill-project/my_forked_bundle and relaunch composer update and the code will be downloaded from your fork.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
composer update
|
||||
|
||||
You may also `use aliases <https://getcomposer.org/doc/articles/aliases.md>`_ to define versions.
|
||||
|
||||
.. _editing-code-and-commiting :
|
||||
|
||||
Editing the code and commiting
|
||||
------------------------------
|
||||
|
||||
You may edit code in the `vendor/path/to/the/bundle` directory.
|
||||
|
||||
Once satisfied with your changes, you should commit as usually :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ cd vendor/path/to/bundle
|
||||
$ git status
|
||||
Sur la branche master
|
||||
Votre branche est à jour avec 'origin/master'.
|
||||
|
||||
rien à valider, la copie de travail est propre
|
||||
|
||||
.. warning
|
||||
|
||||
The git command must be run from you vendor bundle's path (`vendor/path/to/bundle`).
|
||||
|
||||
Tips
|
||||
^^^^
|
||||
|
||||
The command `composer status` (`see composer documentation <https://getcomposer.org/doc/03-cli.md#status>`_) will give you and idea of which bundle has been edited :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ cd ./../../ #back to the root project directory
|
||||
$ composer status
|
||||
You have changes in the following dependencies:
|
||||
/path/to/your/project/install/vendor/chill-project/main
|
||||
Use --verbose (-v) to see modified files
|
||||
|
||||
|
||||
|
||||
|
||||
.. _git: http://git-scm.org
|
||||
.. _composer: https://getcomposer.org
|
49
docs/source/development/localisation.rst
Normal file
@ -0,0 +1,49 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Localisation
|
||||
*************
|
||||
|
||||
Language in url
|
||||
===============
|
||||
|
||||
Language should be present in URL, conventionnaly as first argument.
|
||||
|
||||
.. code-block:: none
|
||||
|
||||
/fr/your/url/here
|
||||
|
||||
This allow users to change from one language to another one on each page, which may be useful in multilanguages teams. If the installation is single-language, the language switcher will not appears.
|
||||
|
||||
This is an example of routing defined in yaml :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_person_general_edit:
|
||||
pattern: /{_locale}/person/{person_id}/general/edit
|
||||
defaults: {_controller: ChillPersonBundle:Person:edit }
|
||||
|
||||
|
||||
Date and time
|
||||
==============
|
||||
|
||||
The `Intl extension <http://twig.sensiolabs.org/doc/extensions/intl.html>`_ is enabled on the Chill application.
|
||||
|
||||
You may format date and time using the `localizeddate` function :
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
date|localizeddate('long', 'none')
|
||||
|
||||
By default, we prefer using the `long` format for date formatting.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Documentation for Intl Extension <http://twig.sensiolabs.org/doc/extensions/intl.html>`_
|
||||
Read the complete doc for the Intl extension.
|
||||
|
50
docs/source/development/logging.rst
Normal file
@ -0,0 +1,50 @@
|
||||
.. Copyright (C) 2016 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
Logging
|
||||
*******
|
||||
|
||||
.. seealso::
|
||||
|
||||
Symfony documentation: `How to user Monolog to write logs <http://symfony.com/doc/current/cookbook/logging/monolog.html>`_
|
||||
The symfony cookbook page about logging.
|
||||
|
||||
|
||||
A channel for custom logging has been created to store sensitive data.
|
||||
|
||||
The channel is named ``chill``.
|
||||
|
||||
The installer of chill should be aware that this channel may contains sensitive data and encrypted during backup.
|
||||
|
||||
Logging to channel `chill`
|
||||
============================
|
||||
|
||||
You should use the service named ``chill.main.logger``, as this :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$logger = $this->get('chill.main.logger');
|
||||
|
||||
You should store data into context, not in the log himself, which should remains the same for the action.
|
||||
|
||||
Example of usage :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
$logger->info("An action has been performed about a person", array(
|
||||
'person_lastname' => $person->getLastName(),
|
||||
'person_firstname' => $person->getFirstName(),
|
||||
'person_id' => $person->getId(),
|
||||
'by_user' => $user->getUsername()
|
||||
));
|
||||
|
||||
For further processing, it is a good idea to separate all fields (like firstname, lastname, ...) into different context keys.
|
||||
|
||||
By convention, you should store the username of the user performing the action under the ``by_user`` key.
|
||||
|
231
docs/source/development/make-test-working.rst
Normal file
@ -0,0 +1,231 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Make tests working
|
||||
******************
|
||||
|
||||
Unit and functional tests are important to ensure that bundle may be deployed securely.
|
||||
|
||||
In reason of the Chill architecture, test should be runnable from the bundle's directory and works correctly: this will allow continuous integration tools to run tests automatically.
|
||||
|
||||
.. note::
|
||||
|
||||
Integration tools (i.e. `travis-ci <https://travis-ci.org>`_) works like this :
|
||||
|
||||
* they clone the bundle repository in a virtual machine, using git
|
||||
* they optionnaly run `composer` to download and install depedencies
|
||||
* they optionnaly run other command to prepare a database, insert fixtures, ...
|
||||
* they run test
|
||||
|
||||
On the developer's machine test should be runnable with two or three commands **runned from the bundle directory** :
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ composer install --dev
|
||||
$ // command to insert fixtures, ...
|
||||
$ phpunit
|
||||
|
||||
This chapter has been inspired by `this useful blog post <http://blog.kevingomez.fr/2013/01/09/functional-testing-standalone-symfony2-bundles/>`_.
|
||||
|
||||
Bootstrap phpunit for a standalone bundle
|
||||
==========================================
|
||||
|
||||
Unit tests should run after achieving this step.
|
||||
|
||||
|
||||
phpunit.xml
|
||||
-----------
|
||||
|
||||
A `phpunit.xml.dist` file should be present at the bundle root.
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
|
||||
<!-- the file "./Tests/boostrap.php" will be created on the next step -->
|
||||
<testsuites>
|
||||
<testsuite name="ChillMain test suite">
|
||||
<directory suffix="Test.php">./Tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Resources</directory>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
</phpunit>
|
||||
|
||||
|
||||
bootstrap.php
|
||||
--------------
|
||||
|
||||
A file `boostrap.php`, located in the `Tests` directory, will allow phpunit to resolve class autoloading :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
|
||||
if (!is_file($autoloadFile = __DIR__.'/../vendor/autoload.php')) {
|
||||
throw new \LogicException('Could not find autoload.php in vendor/. Did you run "composer install --dev"?');
|
||||
}
|
||||
|
||||
require $autoloadFile;
|
||||
|
||||
|
||||
composer.json
|
||||
-------------
|
||||
|
||||
The `composer.json` file **located at the bundle's root** should contains all depencies needed to run test (and to execute bundle functions).
|
||||
|
||||
Ensure that all dependencies are included in the `require` and `require-dev` sections.
|
||||
|
||||
|
||||
Functional tests
|
||||
================
|
||||
|
||||
If you want to access services, database, and run functional tests, you will have to bootstrap a symfony app, with the minimal configuration. Three files are required :
|
||||
|
||||
* a `config_test.yml` file (eventually with a `config.yml`);
|
||||
* a `routing.yml` file
|
||||
* an `AppKernel.php` file
|
||||
|
||||
Adapt phpunit.xml
|
||||
-----------------
|
||||
|
||||
You should add reference to the new application within `phpunit.xml.dist`. The directive `<php>` should be added like this, if your `AppKernel.php` file is located in `Tests/Fixtures/App` directory:
|
||||
|
||||
.. code-block:: xml
|
||||
|
||||
<?xml version="1.0" encoding="UTF-8"?>
|
||||
|
||||
<phpunit bootstrap="./Tests/bootstrap.php" colors="true">
|
||||
<testsuites>
|
||||
<testsuite name="ChillMain test suite">
|
||||
<directory suffix="Test.php">./Tests</directory>
|
||||
</testsuite>
|
||||
</testsuites>
|
||||
<filter>
|
||||
<whitelist>
|
||||
<directory>./</directory>
|
||||
<exclude>
|
||||
<directory>./Resources</directory>
|
||||
<directory>./Tests</directory>
|
||||
<directory>./vendor</directory>
|
||||
</exclude>
|
||||
</whitelist>
|
||||
</filter>
|
||||
<!-- the lines we added -->
|
||||
<php>
|
||||
<server name="KERNEL_DIR" value="./Tests/Fixtures/App/" />
|
||||
</php>
|
||||
</phpunit>
|
||||
|
||||
AppKernel.php
|
||||
-------------
|
||||
|
||||
This file boostrap the app. It contains three functions. This is the file used in the ChillMain bundle :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
<?php
|
||||
|
||||
use Symfony\Component\HttpKernel\Kernel;
|
||||
use Symfony\Component\Config\Loader\LoaderInterface;
|
||||
|
||||
class AppKernel extends Kernel
|
||||
{
|
||||
public function registerBundles()
|
||||
{
|
||||
return array(
|
||||
new Symfony\Bundle\FrameworkBundle\FrameworkBundle(),
|
||||
new Chill\MainBundle\ChillMainBundle(),
|
||||
new Symfony\Bundle\SecurityBundle\SecurityBundle(),
|
||||
new Symfony\Bundle\TwigBundle\TwigBundle(),
|
||||
new \Symfony\Bundle\AsseticBundle\AsseticBundle(),
|
||||
#add here all the required bundle (some bundle are not required)
|
||||
);
|
||||
}
|
||||
|
||||
public function registerContainerConfiguration(LoaderInterface $loader)
|
||||
{
|
||||
$loader->load(__DIR__.'/config/config_'.$this->getEnvironment().'.yml');
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getCacheDir()
|
||||
{
|
||||
return sys_get_temp_dir().'/ChillMainBundle/cache';
|
||||
}
|
||||
|
||||
/**
|
||||
* @return string
|
||||
*/
|
||||
public function getLogDir()
|
||||
{
|
||||
return sys_get_temp_dir().'/ChillMainBundle/logs';
|
||||
}
|
||||
}
|
||||
|
||||
config_test.yml
|
||||
---------------
|
||||
|
||||
There are only few parameters required for the config file. This is a basic version for ChillMain :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# config/config_test.yml
|
||||
imports:
|
||||
- { resource: config.yml } #here we import a config.yml file, this is not required
|
||||
|
||||
framework:
|
||||
test: ~
|
||||
session:
|
||||
storage_id: session.storage.filesystem
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
# config/config.yml
|
||||
framework:
|
||||
secret: Not very secret
|
||||
router: { resource: "%kernel.root_dir%/config/routing.yml" }
|
||||
form: true
|
||||
csrf_protection: true
|
||||
session: ~
|
||||
default_locale: fr
|
||||
translator: { fallback: fr }
|
||||
profiler: { only_exceptions: false }
|
||||
templating: #required for assetic. Remove if not needed
|
||||
engines: ['twig']
|
||||
|
||||
.. note::
|
||||
|
||||
You must adapt config.yml file according to your required bundle. Some options will be missing, other may be removed...
|
||||
|
||||
.. note::
|
||||
|
||||
If you would like to tests different environments, with differents configuration, you could create differents config_XXX.yml files.
|
||||
|
||||
routing.yml
|
||||
------------
|
||||
|
||||
You should add there all routing information needed for your bundle.
|
||||
|
||||
.. code-block: yaml
|
||||
|
||||
chill_main_bundle:
|
||||
resource: "@CLChillMainBundle/Resources/config/routing.yml"
|
||||
|
||||
That's it. Tests should pass.
|
17
docs/source/development/manual/index.rst
Normal file
@ -0,0 +1,17 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Developer manual
|
||||
*****************
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
routing-and-menus.rst
|
||||
|
||||
|
143
docs/source/development/manual/routing-and-menus.rst
Normal file
@ -0,0 +1,143 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Routing and menus
|
||||
*****************
|
||||
|
||||
|
||||
The *Chill*'s architecture allows to choose bundle on each installation. This may lead to a huge diversity of installations, and a the developper challenge is to make his code working with all those possibles installations.
|
||||
|
||||
*Chill* uses menus to let users access easily to the most used functionalities. For instance, when you land on a "Person" page, you may access directly to his activities, notes, documents, ... in a single click on a side menu.
|
||||
|
||||
For a developer, it is easy to extend this menu with his own entries.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Symfony documentation about routing <http://symfony.com/doc/current/book/routing.html>`_
|
||||
This documentation should be read before diving into those lines
|
||||
|
||||
`Routes dans Chill <https://redmine.champs-libres.coop/issues/179>`_ (FR)
|
||||
The issue where we discussed routes. In French.
|
||||
|
||||
Create routes
|
||||
==============
|
||||
|
||||
.. note::
|
||||
|
||||
We recommand using `yaml` to define routes. We have not tested the existing other ways to create routes (annotations, ...). Help wanted.
|
||||
|
||||
The first step is as easy as create a route in symfony, and add some options in his description :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_main_dummy_0:
|
||||
pattern: /dummy/{personId}
|
||||
defaults: { _controller: CLChillMainBundle:Default:index }
|
||||
options:
|
||||
#we begin menu information here :
|
||||
menus:
|
||||
foo: #must appears in menu named 'foo'
|
||||
order: 500 #the order will be '500'
|
||||
label: foolabel #the label shown on menu. Will be translated
|
||||
otherkey: othervalue #you may add other informations, as needed by your layout
|
||||
bar: #must also appears in menu named 'bar'
|
||||
order: 500
|
||||
label: barlabel
|
||||
|
||||
The mandatory parameters under the `menus` definition are :
|
||||
|
||||
* `name`: the menu's name, defined as an key for the following entries
|
||||
* `order`. Note: if we have duplicate order's values, the order will be incremented. We recommand using big intervals within orders and publishing the orders in your documentation
|
||||
* `label`: the text which will be rendered inside the `<a>` tag. The label should be processed trough the `trans` filter (`{{ route.label|trans }}`)
|
||||
|
||||
You *may* also add other keys, which will be used optionally in the way the menu is rendered. See
|
||||
|
||||
.. warning::
|
||||
|
||||
Although all keys will be kept from your `yaml` definition to your menu template, we recommend not using those keys, which are reserved for a future implementations of Chill :
|
||||
|
||||
* `helper`, a text to help user or add more informations to him
|
||||
* `access` : which will run a test with `Expression Langage <http://symfony.com/doc/current/components/expression_language/index.html>`_ to determine if the user has the ACL to show the menu entry ;
|
||||
* `condition`, which will test with the menu context if the entry must appears
|
||||
|
||||
Show menu in twig templates
|
||||
===========================
|
||||
|
||||
To show our previous menu in the twig template, we invoke the `chill_menu` function. This will render the `foo` menu :
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ chill_menu('foo') }}
|
||||
|
||||
Passing variables
|
||||
^^^^^^^^^^^^^^^^^
|
||||
|
||||
If your routes need arguments, i.e. an entity id, you should pass the as argument to the chill_menu function. If your route's pattern is `/person/{personId}`, your code become :
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ chill_menu('foo', { 'args' : { 'personId' : person.id } } ) }}
|
||||
|
||||
Of course, `person` is a variable you must define in your code, which should have an `id` accessible property (i.e. : `$person->getId()`).
|
||||
|
||||
.. note::
|
||||
|
||||
Be aware that your arguments will be passed to all routes in a menu. If a route does not require `personId` in his pattern, the route will become `/pattern?personId=XYZ`. This should not cause problem in your application.
|
||||
|
||||
.. warning::
|
||||
|
||||
It is a good idea to reuse the same parameter's name in your pattern, to avoid collision. Prefer `/person/{personId}` to `/person/{id}`.
|
||||
|
||||
If you don't do that and another developer create a bundle with `person/{personId}/{id}` where `{id}` is the key for something else, this will cause a lot of trouble...
|
||||
|
||||
Rendering active entry
|
||||
^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Now, you want to render differently the *active* route of the menu [#f1]_. You should, in your controller or template, add the active route in your menu :
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ chill_menu('foo', { 'activeRouteKey' : 'chill_main_dummy_0' } ) }}
|
||||
|
||||
On menu creation, the route wich has the key `chill_main_dummy_0` will be rendered on a different manner.
|
||||
|
||||
Define your own template
|
||||
-------------------------
|
||||
|
||||
By default, the menu is rendered with the default template, which is a simple `ul` list. You may create your own templates :
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
#MyBundle/Resources/views/Menu/MyMenu.html.twig
|
||||
<ul class="myMenu">
|
||||
{% for route in routes %}
|
||||
<li><a href="{{ path(route.key, args ) }}" class="{%- if activeRouteKey == route.key -%}active{%- endif -%}">{{ route.label|trans }}</a></li>
|
||||
{% endfor %}
|
||||
</ul>
|
||||
|
||||
Arguments available in your template :
|
||||
|
||||
* The `args` value are the value passed in the 'args' arguments requested by the `chill_menu` function.
|
||||
* `activeRouteKey` is the key of the currently active route.
|
||||
* `routes` is an array of routes. The array has this structure: `routes[order] = { 'key' : 'the_route_key', 'label' : 'the route label' }` The order is *resolved*: in case of collision (two routes from different bundles having the same order), the order will be incremented. You may find in the array your own keys (`{ 'otherkey' : 'othervalue'}` in the example above).
|
||||
|
||||
Then, you will call your own template with the `layout` argument :
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
{{ chill_menu('foo', { 'layout' : 'MyBundle:Menu:MyMenu.html.twig' } ) }}
|
||||
|
||||
.. note::
|
||||
|
||||
Take care of specifying the absolute path to layout in the function.
|
||||
|
||||
|
||||
|
||||
.. rubric:: Footnotes
|
||||
|
||||
.. [#f1] In the default template, the currently active entry will be rendered with an "active" class : `<li class="active"> ... </li>`
|
123
docs/source/development/menus.rst
Normal file
@ -0,0 +1,123 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
.. _menus :
|
||||
|
||||
Menus
|
||||
*****
|
||||
|
||||
Chill has created his own menu system
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Routes dans Chill [specification] <https://redmine.champs-libres.coop/issues/179>`_
|
||||
The issue wich discussed the implementation of routes.
|
||||
|
||||
Concepts
|
||||
========
|
||||
|
||||
.. warning::
|
||||
|
||||
to be written
|
||||
|
||||
|
||||
|
||||
Add a menu in a template
|
||||
========================
|
||||
|
||||
In your twig template, use the `chill_menu` function :
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{{ chill_menu('person', {
|
||||
'layout': 'ChillPersonBundle::menu.html.twig',
|
||||
'args' : {'id': person.id },
|
||||
'activeRouteKey': 'chill_person_view'
|
||||
}) }}
|
||||
|
||||
The available arguments are:
|
||||
|
||||
* `layout` : a custom layout. Default to `ChillMainBundle:Menu:defaultMenu.html.twig`
|
||||
* `args` : those arguments will be passed through the url generator.
|
||||
* `activeRouteKey` must be the route key name.
|
||||
|
||||
.. note::
|
||||
|
||||
The argument `activeRouteKey` may be a twig variable, defined elsewhere in your template, even in child templates.
|
||||
|
||||
|
||||
|
||||
Create an entry in an existing menu
|
||||
===================================
|
||||
|
||||
If a route belongs to a menu, you simply add this to his definition in routing.yml :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_person_history_list:
|
||||
pattern: /person/{person_id}/history
|
||||
defaults: { _controller: ChillPersonBundle:History:list }
|
||||
options:
|
||||
#declare menus
|
||||
menus:
|
||||
# the route should be in 'person' menu :
|
||||
person:
|
||||
#and have those arguments :
|
||||
order: 100
|
||||
label: menu.person.history
|
||||
|
||||
* `order` (mandatory) : the order in the menu. It is preferrable to increment by far more than 1.
|
||||
* `label` (mandatory) : a translatable string.
|
||||
* `helper` (optional) : a text to help people to understand what does the menu do. Not used in default implementation.
|
||||
* `condition` (optional) : an `Expression Language <http://symfony.com/doc/current/components/expression_language/index.html> `_ which will make the menu appears or not. Typically, it may be used to say "show this menu only if the person concerned is more than 18". **Not implemented yet**.
|
||||
* `access` (optional) : an Expression Language to evalute the possibility, for the user, to show this menu according to Access Control Model. **Not implemented yet.**
|
||||
|
||||
You may add additional keys, but should not use the keys described above.
|
||||
|
||||
You may add the same route to multiple menus :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_person_history_list:
|
||||
pattern: /person/{person_id}/history
|
||||
defaults: { _controller: ChillPersonBundle:History:list }
|
||||
options:
|
||||
menus:
|
||||
menu1:
|
||||
order: 100
|
||||
label: menu.person.history
|
||||
menu2:
|
||||
order: 100
|
||||
label: another.label
|
||||
|
||||
|
||||
|
||||
Customize menu rendering
|
||||
========================
|
||||
|
||||
You may customize menu rendering by using the `layout` option.
|
||||
|
||||
.. warning ::
|
||||
|
||||
TODO : this part should be written.
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
.. _caveats :
|
||||
|
||||
Caveats
|
||||
=======
|
||||
|
||||
Currently, you may pass arguments globally to each menu, and they will be all passed to route url. This means that :
|
||||
|
||||
* the argument name in the route entry must match the argument key in menu declaration in twig template
|
||||
* if an argument is missing to generate an url, the url generator will throw a `Symfony\Component\Routing\Exception\MissingMandatoryParametersException`
|
||||
* if the argument name is not declared in route entry, it will be added to the url, (example: `/my/route?additional=foo`)
|
129
docs/source/development/messages-to-users.rst
Normal file
@ -0,0 +1,129 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Messages to users, flashbags and buttons
|
||||
****************************************
|
||||
|
||||
|
||||
.. _flashbags :
|
||||
|
||||
Flashbags
|
||||
==========
|
||||
|
||||
The four following levels are defined :
|
||||
|
||||
+-----------+----------------------------------------------------------------------------------------------+
|
||||
|Key |Intent |
|
||||
+===========+==============================================================================================+
|
||||
|alert |A message not linked with the user action, but which should require an action or a |
|
||||
| |correction. |
|
||||
+-----------+----------------------------------------------------------------------------------------------+
|
||||
|success |The user action succeeds. |
|
||||
+-----------+----------------------------------------------------------------------------------------------+
|
||||
|notice |A simple message to give information to the user. The message may be linked or not linked with|
|
||||
| |the user action. |
|
||||
+-----------+----------------------------------------------------------------------------------------------+
|
||||
|warning |A message linked with an action, the user should correct. |
|
||||
+-----------+----------------------------------------------------------------------------------------------+
|
||||
|error |The user's action failed: he must correct something to process the action. |
|
||||
+-----------+----------------------------------------------------------------------------------------------+
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Flash Messages on Symfony documentation <http://symfony.com/doc/current/book/controller.html#flash-messages>`_
|
||||
Learn how to use flash messages in controller.
|
||||
|
||||
|
||||
Buttons
|
||||
========
|
||||
|
||||
Some actions are available to decorate ``a`` links and ``buttons``.
|
||||
|
||||
To add the action on button, use them as class along with ``sc-button`` :
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<a class="sc-button bt-create">Create an entity</a>
|
||||
|
||||
<button class="sc-button bt-submit" type="submit">Submit</button>
|
||||
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Action | Class | Description |
|
||||
+===========+================+==============================================================================+
|
||||
| Submit | ``bt-submit`` | Submit a form. Use only if action is not "save". |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Create | ``bt-create`` | - Link to a form to create an entity (alias: ``bt-new``) |
|
||||
| | or ``bt-new`` | - Submitting this form will create a new entity |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Reset | ``bt-reset`` | Reset a form |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Delete | ``bt-delete`` | - Link to a form to delete an entity |
|
||||
| | | - Submitting this form will remove the entity |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Edit | ``bt-edit`` or | Link to a form to edit an entity |
|
||||
| | ``bt-update`` | |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Save | ``bt-save`` | Submitting this form will save change on the entity |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Action | ``bt-action`` | Generic link to an action |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
| Cancel | ``bt-cancel`` | Cancel an action and go back to another page |
|
||||
+-----------+----------------+------------------------------------------------------------------------------+
|
||||
|
||||
Styling buttons
|
||||
---------------
|
||||
|
||||
Small buttons, mainly to use inline
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<p><a class="sc-button bt-create bt-small">You button</a></p>
|
||||
|
||||
You can omit content and show a button with an icon only :
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<a class="sc-button bt-create"></a>
|
||||
|
||||
You can hide content and show it only on hover
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<a class="sc-button bt-create has-hidden"><span class="show-on-hover">Showed when mouse pass on</span></a>
|
||||
|
||||
You can customize the icon :
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<a class="sc-button bt-create change-icon"><i class="fa fa-icon"></i>Button with custom icon</a>
|
||||
|
||||
Grouping buttons
|
||||
----------------
|
||||
|
||||
Grouping buttons can be done using ``ul.record_actions`` element (an ``ul`` list with class ``record_actions``):
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<ul class="record_actions">
|
||||
|
||||
<li class="cancel">
|
||||
<a class="sc-button bt-cancel">Cancel</a>
|
||||
<li>
|
||||
|
||||
<li>
|
||||
<a class="sc-button bt-save">Save</a>
|
||||
</li>
|
||||
|
||||
</ul>
|
||||
|
||||
The element with the ``cancel`` class will be set in first position.
|
||||
|
||||
Inside table, the space between elements will be shorter.
|
||||
|
||||
You can add the class ``record_actions_small`` if you want shorter space between elements.
|
||||
|
101
docs/source/development/migrations.rst
Normal file
@ -0,0 +1,101 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Database Migrations
|
||||
********************
|
||||
|
||||
Every bundle potentially brings his own database operations : to persist entities, developers have to create database schema, creating indexes,...
|
||||
|
||||
Those schema might be changed (the less is the better) from time to time.
|
||||
|
||||
Consequence: each bundle should bring his own migration files, which will bring the database consistent with the operation you will run in your code. They will be gathered into the app installation, ready to be executed by the chill's installer.
|
||||
|
||||
Currently, we use `doctrine migration`_ to manage those migration files. A `composer`_ script located in the **chill standard** component will copy the migrations from your bundle to the doctrne migration's excepted directory after each install and/or update operation.
|
||||
|
||||
.. seealso::
|
||||
|
||||
The `doctrine migration`_ documentation
|
||||
Learn concepts about migrations files and scripts and the doctrine ORM
|
||||
|
||||
The `doctrine migration bundle`_ documentation
|
||||
Learn about doctrine migration integration with Symfony framework
|
||||
|
||||
Shipping migration files
|
||||
========================
|
||||
|
||||
Migrations files should be shipped under the Resource/migrations directory. You could customize the migration directory by adding extra information in your composer.json:
|
||||
|
||||
.. code-block:: json
|
||||
|
||||
"extra": {
|
||||
"migration-source": "path/to/my/dir"
|
||||
}
|
||||
|
||||
The class namespace should be `Application\Migrations`, as expected by doctrine migration. Only the files which will be executed by doctrine migration will be moved: they must have the pattern `VersionYYYYMMDDHHMMSS.php` where YYYY is the year, MM the month, DD the day, HH the hour, MM the month and SS the second of creation.
|
||||
|
||||
They will be moved automatically by composer when you install or update a bundle.
|
||||
|
||||
Executing migration files
|
||||
==========================
|
||||
|
||||
The installers will have to execute migrations files manually, running
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
php app/console doctrine:migrations:status #will give the current status of the database
|
||||
php app/console doctrine:migrations:migrate #process the update
|
||||
|
||||
|
||||
Updating migration files
|
||||
=========================
|
||||
|
||||
.. warning::
|
||||
|
||||
After an installation, migration files will be executed and registered as executed in the database (the version timestamp is recorded into the :title:`migrations_versions` table). If you update your migration file code, the file will still be considered as "executed" by doctrine migration, which will not offers the possibility to run the migration again.
|
||||
|
||||
Consequently, updating migration file should only be considered during development phase, and not published on public git branches. If you want to edit your database schema, you should create a new migration file, with a new timestamp, which will proceed to your schema adaptations.
|
||||
|
||||
Every time a migration file is discovered, the composer'script will check if the migration exists in the local migration directory. If yes, the script will compare two file for changes (using a md5 hash). If migrations are discovered, the script will ask the installer to know if he must replace the file or ignore it.
|
||||
|
||||
.. note::
|
||||
|
||||
You can manually run composer script by launching `composer run-script post-update-cmd` from your root chill installation's directory.
|
||||
|
||||
|
||||
.. _doctrine migration: http://www.doctrine-project.org/projects/migrations.html
|
||||
.. _doctrine migration bundle : http://symfony.com/doc/master/bundles/DoctrineMigrationsBundle/index.html
|
||||
.. _composer : https://getcomposer.org
|
||||
|
||||
Tips for development
|
||||
====================
|
||||
|
||||
Migration and data
|
||||
------------------
|
||||
|
||||
Each time you create a migration script, you should ensure that it will not lead to data losing. Eventually, feel free to use intermediate steps.
|
||||
|
||||
Generation
|
||||
----------
|
||||
|
||||
You can generate migration file from the command line, using those commands:
|
||||
|
||||
* `php app/console doctrine:migrations:diff` to generate a migration file by comparing your current database to your mapping information
|
||||
* `php app/console doctrine:migrations:generate` to generate a blank migration file.
|
||||
|
||||
Those files will be located into `app/DoctrineMigrations` directory. You will have to copy those file to your the directory `Resources/migrations` into your bundle directory.
|
||||
|
||||
Comments and documentation
|
||||
--------------------------
|
||||
|
||||
As files are copied from your bundle to the `app/DoctrineMigrations` directory, the link between your bundle and the copied file will be unclear. Please add all relevant documentation which will allow future developers to make a link between your file and your bundle.
|
||||
|
||||
Inside the script
|
||||
-----------------
|
||||
|
||||
The script which move the migrations files to app directory `might be found here
|
||||
<https://github.com/Champs-Libres/ComposerBundleMigration/blob/master/Composer/Migrations.php>
|
189
docs/source/development/pagination.rst
Normal file
@ -0,0 +1,189 @@
|
||||
.. Copyright (C) 2016 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
Pagination
|
||||
##########
|
||||
|
||||
The Bundle :code:`Chill\MainBundle` provides a **Pagination** api which allow you to easily divide results list on different pages.
|
||||
|
||||
A simple example
|
||||
****************
|
||||
|
||||
In the controller, get the :class:`Chill\Main\Pagination\PaginatorFactory` from the `Container` and use this :code:`PaginatorFactory` to create a :code:`Paginator` instance.
|
||||
|
||||
|
||||
.. literalinclude:: pagination/example.php
|
||||
:language: php
|
||||
|
||||
|
||||
Then, render the pagination using the dedicated twig function.
|
||||
|
||||
.. code-block:: html+twig
|
||||
|
||||
{% extends "ChillPersonBundle::layout.html.twig" %}
|
||||
|
||||
{% block title 'Item list'|trans %}
|
||||
|
||||
{% block personcontent %}
|
||||
|
||||
<table>
|
||||
|
||||
{# ... your items here... #}
|
||||
|
||||
</table>
|
||||
|
||||
{% if items|length < paginator.getTotalItems %}
|
||||
{{ chill_pagination(paginator) }}
|
||||
{% endif %}
|
||||
|
||||
|
||||
The function :code:`chill_pagination` will, by default, render a link to the 10 previous page (if they exists) and the 10 next pages (if they exists). Assuming that we are on page 5, the function will render a list to ::
|
||||
|
||||
Previous 1 2 3 4 **5** 6 7 8 9 10 11 12 13 14 Next
|
||||
|
||||
Understanding the magic
|
||||
=======================
|
||||
|
||||
Where does the :code:`$paginator` get the page number ?
|
||||
-------------------------------------------------------
|
||||
|
||||
Internally, the :code:`$paginator` object has a link to the :code:`Request` object, and it reads the :code:`page` parameter which contains the current page number. If this parameter is not present, the :code:`$paginator` assumes that we are on page 1.
|
||||
|
||||
.. figure:: /_static/puml/pagination-sequence.png
|
||||
|
||||
The :code:`$paginator` get the current page from the request.
|
||||
|
||||
Where does the :code:`$paginator` get the number of items per page ?
|
||||
--------------------------------------------------------------------
|
||||
|
||||
As above, the :code:`$paginator` can get the number of items per page from the :code:`Request`. If none is provided, this is given by the configuration which is, by default, 50 items per page.
|
||||
|
||||
:code:`PaginatorFactory`, :code:`Paginator` and :code:`Page`
|
||||
************************************************************
|
||||
|
||||
:code:`PaginatorFactory`
|
||||
========================
|
||||
|
||||
The :code:`PaginatorFactory` may create more than one :code:`Paginator` in a single action. Those :code:`Paginator` instance may redirect to different routes and/or routes parameters.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// create a paginator for the route 'my_route' with some parameters (arg1 and arg2)
|
||||
$paginatorMyRoute = $paginatorFactory->create($total, 'my_route', array('arg1' => 'foo', 'arg2' => $bar);
|
||||
|
||||
Those parameters will override the current parameters.
|
||||
|
||||
The :code:`PaginatorFactory` has also some useful shortcuts :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// get current page number
|
||||
$paginatorFactory->getCurrentPageNumber( )
|
||||
// get the number of items per page **for the current request**
|
||||
$paginatorFactory->getCurrentItemsPerPage( )
|
||||
// get the number of the first item **for the current page**
|
||||
$paginatorFactory->getCurrentPageFirstItemNumber( )
|
||||
|
||||
|
||||
Working with :code:`Paginator` and :code:`Page`
|
||||
===============================================
|
||||
|
||||
The paginator has some function to give the number of pages are required to displayed all the results, and give some information about the number of items per page :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// how many page count this paginator ?
|
||||
$paginator->countPages(); // return 20 in our example
|
||||
|
||||
// we may get the number of items per page
|
||||
$paginator->getItemsPerPage(); // return 20 in our example
|
||||
|
||||
A :code:`Paginator` instance create instance of :code:`Page`, each :code:`Page`, which is responsible for generating the URL to the page number it represents. Here are some possibilities using :code:`Page` and :code:`Paginator` :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// get the current page
|
||||
$page = $paginator->getCurrentPage();
|
||||
// on which page are we ?
|
||||
$page->getNumber(); // return 5 in this example (we are on page 5)
|
||||
// generate the url for page 5
|
||||
$page->generateUrl(); // return '/<your route here>?page=5
|
||||
// what is the first item number on this page ?
|
||||
$page->getFistItemNumber(); // return 101 in our example (20 items per page)
|
||||
// what is the last item number on this page ?
|
||||
$page->getLastItemNumber(); // return 120 in our example
|
||||
|
||||
// we can access directly the next and current page
|
||||
if ($paginator->hasNextPage()) {
|
||||
$next = $paginator->getNextPage();
|
||||
}
|
||||
if ($paginator->hasPreviousPage()) {
|
||||
$previous = $paginator->getPreviousPage();
|
||||
}
|
||||
|
||||
// we can access directly to a given page number
|
||||
if ($paginator->hasPage(10)) {
|
||||
$page10 = $paginator->getPage(10);
|
||||
}
|
||||
|
||||
// we can iterate over our pages through a generator
|
||||
foreach ($paginator->getPagesGenerator() as $page) {
|
||||
$page->getNumber();
|
||||
}
|
||||
|
||||
// check that a page object is the current page
|
||||
$paginator->isCurrentPage($page); // return false
|
||||
|
||||
.. warning::
|
||||
|
||||
When calling a page which does not exists, the :code:`Paginator` will throw a `RuntimeException`. Example :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// our last page is 10
|
||||
$paginator->getPage(99); // out of range => throw `RuntimeException`
|
||||
|
||||
// our current page is 1 (the first page)
|
||||
$paginator->getPreviousPage; // does not exists (the fist page is always 1) => throw `RuntimeException`
|
||||
|
||||
.. note::
|
||||
|
||||
When you create a :code:`Paginator` for the current route and route parameters, the :code:`Page` instances will keep the same parameters and routes :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
// assuming our route is 'my_route', for the pattern '/my/{foo}/route',
|
||||
// and the current route is '/my/value/route?arg2=bar'
|
||||
|
||||
// create a paginator for the current route and route parameters :
|
||||
$paginator = $paginatorFactory->create($total);
|
||||
|
||||
// get the next page
|
||||
if ($paginator->hasNext()) {
|
||||
$next = $paginator->getNextPage();
|
||||
|
||||
// get the route to the page
|
||||
$page->generateUrl(); // will print 'my/value/route?arg2=bar&page=2'
|
||||
}
|
||||
|
||||
|
||||
Having a look to the `full classes documentation may provide some useful information <http://api.chill.social/Chill-Main/master/namespace-Chill.MainBundle.Pagination.html>`_.
|
||||
|
||||
|
||||
Customizing the rendering of twig's :code:`chill_pagination`
|
||||
************************************************************
|
||||
|
||||
You can provide your own layout for rendering the pagination: provides your twig template as a second argument :
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{{ chill_pagination(paginator, 'MyBundle:Pagination:MyTemplate.html.twig') }}
|
||||
|
||||
The template will receive the :code:`$paginator` as :code:`paginator` variable. Let's have a look `at the current template <https://framagit.org/Chill-project/Chill-Main/blob/master/Resources/views/Pagination/long.html.twig>`_.
|
||||
|
42
docs/source/development/pagination/example.php
Normal file
@ -0,0 +1,42 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\MyBundle\Controller;
|
||||
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
|
||||
|
||||
class ItemController extends Controller {
|
||||
|
||||
public function yourAction()
|
||||
{
|
||||
$em = $this->getDoctrine()->getManager();
|
||||
// first, get the number of total item are available
|
||||
$total = $em
|
||||
->createQuery("SELECT COUNT (item.id) FROM ChillMyBundle:Item item")
|
||||
->getSingleScalarResult();
|
||||
|
||||
// get the PaginatorFactory
|
||||
$paginatorFactory = $this->get('chill_main.paginator_factory');
|
||||
|
||||
// create a pagination instance. This instance is only valid for
|
||||
// the current route and parameters
|
||||
$paginator = $paginatorFactory->create($total);
|
||||
|
||||
// launch your query on item. Limit the query to the results
|
||||
// for the current page using the paginator
|
||||
$items = $em->createQuery("SELECT item FROM ChillMyBundle:Item item WHERE <your clause>")
|
||||
// use the paginator to get the first item number
|
||||
->setFirstResult($paginator->getCurrentPage()->getFirstItemNumber())
|
||||
// use the paginator to get the number of items to display
|
||||
->setMaxResults($paginator->getItemsPerPage());
|
||||
|
||||
return $this->render('ChillMyBundle:Item:list.html.twig', array(
|
||||
'items' => $items,
|
||||
'paginator' => $paginator
|
||||
);
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
68
docs/source/development/routing.rst
Normal file
@ -0,0 +1,68 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
Routing
|
||||
#######
|
||||
|
||||
Our goal is to ease the installation of the different bundle. Users should not have to dive into complicated config files to install bundles.
|
||||
|
||||
A routing loader available for all bundles
|
||||
===========================================
|
||||
|
||||
A Chill bundle may rely on the Routing Loader defined in ChillMain.
|
||||
|
||||
The loader will load `yml` or `xml` files. You simply have to add them into `chill_main` config
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
chill_main:
|
||||
# ... other stuff here
|
||||
routing:
|
||||
resources:
|
||||
- @ChillMyBundle/Resources/config/routing.yml
|
||||
|
||||
Load routes automatically
|
||||
-------------------------
|
||||
|
||||
But this force users to modify config files. To avoid this, you may prepend config implementing the `PrependExtensionInterface` in the `YourBundleExtension` class. This is an example from **chill main** bundle :
|
||||
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
|
||||
class ChillMainExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
|
||||
//add current route to chill main
|
||||
//this is where the resource is added automatically in the config
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillMainBundle/Resources/config/routing.yml'
|
||||
)
|
||||
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
276
docs/source/development/searching.rst
Normal file
@ -0,0 +1,276 @@
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
Searching
|
||||
*********
|
||||
|
||||
Chill should provide information needed by users when they need it. Searching within bundle, entities,... is an important feature to achieve this goal.
|
||||
|
||||
The Main Bundle provide interfaces to ease the developer work. It will also attempt that search will work in the same way accross bundles.
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
.. seealso::
|
||||
|
||||
`Our blog post about searching (in French) <http://blog.champs-libres.coop/vie-des-champs/2015/01/06/va-chercher-chill-la-recherche-dans-chill-logiciel-libre-service-social.html>`_
|
||||
This blog post give some information for end-users about searching.
|
||||
|
||||
`The issue about search behaviour <https://redmine.champs-libres.coop/issues/377>`_
|
||||
Where the search behaviour is defined.
|
||||
|
||||
Searching in a glance for developers
|
||||
====================================
|
||||
|
||||
Chill suggests to use an easy-to-learn language search.
|
||||
|
||||
.. note::
|
||||
|
||||
We are planning to provide a form to create automatically search pattern according to this language. Watch the `issue regarding this feature <https://redmine.champs-libres.coop/issues/389>`_.
|
||||
|
||||
The language is an association of search terms. Search terms may contains :
|
||||
|
||||
- **a domain**: this is "the domain you want to search" : it may some entities like people, reports, ... Example : `@person` to search accross people, `@report` to browse reports, ... The search pattern may have **a maximum of one** domain by search, providing more should throw an error, and trigger a warning for users.
|
||||
- **arguments and their values** : This is "what you search". Arguments narrow the search to specific fields : username, date of birth, nationality, ... The syntax is `argument:value`. I.e.: ` birthdate:2014-12-15`, `firstname:Depardieu`, ... **Arguments are optional**. If the value of an argument contains spaces or characters like punctuation, quotes ("), the value should be provided between parenthesis : `firstname:(Van de snoeck)`, `firstname:(M'bola)`, ...
|
||||
- **default value** : this the "rest" of the search, not linked with any arguments or domain. Example : `@person dep` (`dep` is the "default value"), or simply `dep` if any domain is provided (which is perfectly acceptable). If a string is not idenfied as argument or domain, it will be present in the "default" term.
|
||||
|
||||
If a search pattern (provided by the user) does not contains any domain, the search must be run across default domain/search modules.
|
||||
|
||||
A domain may be supported by different search modules. For instance, if you provide the domain `@person`, the end-user may receive results of exact firstname/lastname, but also result with spelling suggestion, ... **But** if results do not fit into the first page (if you have 75 results and the screen show only 50 results), the next page should contains only the results from the required module.
|
||||
|
||||
For instance : a user search across people by firstname/lastname, the exact spelling contains 10 results, the "spelling suggestion" results contains 75 names, but show only the first 50. If the user want to see the last 25, the next screen should not contains the results by firstname/lastname.
|
||||
|
||||
Allowed characters as arguments
|
||||
===============================
|
||||
|
||||
In order to execute regular expression, the allowed chararcters in arguments are a-z characters, numbers, and the sign '-'. Spaces and special characters like accents are note allowed (the accents are removed during parsing).
|
||||
|
||||
Special characters and uppercase
|
||||
================================
|
||||
|
||||
The search should not care about lowercase/uppercase and accentued characters. Currently, they are removed automatically by the `chill.main.search_provider`.
|
||||
|
||||
Implementing search module for dev
|
||||
===================================
|
||||
|
||||
To implement a search module, you should :
|
||||
|
||||
- create a class which implements the `Chill\MainBundle\Search\SearchInterface` class. An abstract class `Chill\MainBundle\Search\AbstractSearch` will provide useful assertions for parsing date string to `DateTime` objects, ...
|
||||
- register the class as a service, and tag the service with `chill.search` and an appropriate alias
|
||||
|
||||
The search logic is provided under the `/search` route.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`The implementation of a search module in Person bundle <https://github.com/Chill-project/Person/blob/master/Search/PersonSearch.php>`_
|
||||
An example of implementationhttps://github.com/Chill-project/Main/blob/master/DependencyInjection/SearchableServicesCompilerPass.php
|
||||
|
||||
.. note::
|
||||
|
||||
**Internals explained** : the services tagged with `chill.search` are gathered into the `chill.main.search_provider` service during compilation (`see the compiler pass <https://github.com/Chill-project/Main/blob/master/DependencyInjection/SearchableServicesCompilerPass.php>`_).
|
||||
|
||||
The `chill.main.search_provider` service allow to :
|
||||
|
||||
- retrieve all results (as html string) for all search module concerned by the search (according to the domain provided or modules marked as default)
|
||||
- retrieve result for one search module
|
||||
|
||||
The SearchInterface class
|
||||
-------------------------
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\Search;
|
||||
|
||||
use Chill\MainBundle\Search\AbstractSearch;
|
||||
use Doctrine\ORM\EntityManagerInterface;
|
||||
use Chill\PersonBundle\Entity\Person;
|
||||
use Symfony\Component\DependencyInjection\ContainerInterface;
|
||||
use Symfony\Component\DependencyInjection\ContainerAware;
|
||||
use Symfony\Component\DependencyInjection\ContainerAwareTrait;
|
||||
use Chill\MainBundle\Search\ParsingException;
|
||||
|
||||
class PersonSearch extends AbstractSearch
|
||||
{
|
||||
|
||||
// indicate which domain you support
|
||||
// you may respond TRUE to multiple domain, according to your logic
|
||||
public function supports($domain, $format='html')
|
||||
{
|
||||
return 'person' === $domain;
|
||||
}
|
||||
|
||||
// if your domain must be called when no domain is provided, should return true
|
||||
public function isActiveByDefault()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
// if multiple module respond to the same domain, indicate an order for your search.
|
||||
public function getOrder()
|
||||
{
|
||||
return 100;
|
||||
}
|
||||
|
||||
|
||||
// This is where your search logic should be executed.
|
||||
// This method must return an HTML string (a string with HTML tags)
|
||||
// see below about the structure of the $term array
|
||||
public function renderResult(array $terms, $start = 0, $limit = 50, array $options = array(), $format = 'html')
|
||||
{
|
||||
return $this->container->get('templating')->render('ChillPersonBundle:Person:list.html.twig',
|
||||
array(
|
||||
// you should implements the `search` function somewhere :-)
|
||||
'persons' => $this->search($terms, $start, $limit, $options),
|
||||
// recomposePattern is available in AbstractSearch class
|
||||
'pattern' => $this->recomposePattern($terms, array('nationality',
|
||||
'firstname', 'lastname', 'birthdate', 'gender'), $terms['_domain']),
|
||||
// you should implement the `count` function somewhere :-)
|
||||
'total' => $this->count($terms)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Values for :code:`$options`
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
:code:`$options` is an array with the following keys:
|
||||
|
||||
- :code:`SearchInterface::SEARCH_PREVIEW_OPTION` (bool): if the current view is a preview (the first 5 results) or not ;
|
||||
- :code:`SearchInterface::REQUEST_QUERY_PARAMETERS` (bool): some parameters added to the query (under the key :code:`SearchInterface::REQUEST_QUERY_KEY_ADD_PARAMETERS`) and that can be interpreted. Used, for instance, when calling a result in json format when searching for interactive picker form.
|
||||
|
||||
|
||||
|
||||
|
||||
Structure of array `$term`
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The array term is parsed automatically by the `main.chill.search_provider` service.
|
||||
|
||||
.. note::
|
||||
If you need to parse a search pattern, you may use the function `parse($pattern)` provided by the service.
|
||||
|
||||
The array `$term` have the following structure after parsing :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
array(
|
||||
'_domain' => 'person', //the domain, without the '@'
|
||||
'argument1' => 'value', //the argument1, with his value
|
||||
'argument2' => 'my value with spaces', //the argument2
|
||||
'_default' => 'abcde ef' // the default term
|
||||
);
|
||||
|
||||
The original search would have been : `@person argument1:value argument2:(my value with spaces) abcde ef`
|
||||
|
||||
.. warning::
|
||||
The search values are always unaccented.
|
||||
|
||||
Returning a result in json
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The json format is mainly used by "select2" widgets.
|
||||
|
||||
When returning a result in json, the SearchInterface should only return an array with following keys:
|
||||
|
||||
- :code:`more` (bool): if the search has more result than the current page ;
|
||||
- :code:`results` (array): a list of result, where:
|
||||
|
||||
- :code:`text` (string): the text that should be displayed in browser ;
|
||||
- :code:`id` (string): the id of the entity.
|
||||
|
||||
|
||||
|
||||
Register the service
|
||||
--------------------
|
||||
|
||||
You should add your service in the configuration, and add a `chill.search` tag and an alias.
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
services:
|
||||
chill.person.search_person:
|
||||
class: Chill\PersonBundle\Search\PersonSearch
|
||||
#your logic here
|
||||
tags:
|
||||
- { name: chill.search, alias: 'person_regular' }
|
||||
|
||||
The alias will be used to get the results narrowed to this search module, in case of pagination (see above).
|
||||
|
||||
Parsing date
|
||||
============
|
||||
|
||||
The class `Chill\MainBundle\Search\AbstractSearch` provides a method to parse date :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
//from subclasses
|
||||
$date = $this->parseDate($string);
|
||||
|
||||
`$date` will be an instance of `DateTime <http://php.net/manual/en/class.datetime.php>`_.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`The possibility to add periods instead of date <https://redmine.champs-libres.coop/issues/390>`_
|
||||
Which may be a future improvement for search with date.
|
||||
|
||||
Exceptions
|
||||
==========
|
||||
|
||||
The logic of the search is handled by the controller for the `/search` path.
|
||||
|
||||
You should throw those Exception from your instance of `SearchInterface` if needed :
|
||||
|
||||
Chill\MainBundle\Search\ParsingException
|
||||
If the terms does not fit your search logic (for instance, conflicting terms)
|
||||
|
||||
Expected behaviour
|
||||
==================
|
||||
|
||||
Operators between multiple terms
|
||||
--------------------------------
|
||||
|
||||
Multiple terms should be considered are "AND" instructions :
|
||||
|
||||
@person nationality:RU firstname:dep
|
||||
the people having the Russian nationality AND having DEP in their name
|
||||
|
||||
@person birthdate:2015-12-12 charles
|
||||
the people having 'charles' in their name or firstname AND born on December 12 2015
|
||||
|
||||
Spaces in default
|
||||
-----------------
|
||||
|
||||
Spaces in default terms should be considered as "AND" instruction
|
||||
|
||||
@person charle dep
|
||||
people having "dep" AND "charles" in their firstname or lastname. Match "Charles Depardieu" but not "Gérard Depardieu" ('charle' is not present)
|
||||
|
||||
Rendering
|
||||
---------
|
||||
|
||||
The rendering should contains :
|
||||
|
||||
- the total number of results ;
|
||||
- the search pattern in the search language. The aim of this is to let users learn the search language easily.
|
||||
- a title
|
||||
|
||||
Frequently Asked Questions (FAQ)
|
||||
================================
|
||||
|
||||
Why renderResults returns an HTML string and not structured array ?
|
||||
It seems that the form of results may vary (according to access-right logic, ...) and is not easily structurable
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
377
docs/source/development/timelines.rst
Normal file
@ -0,0 +1,377 @@
|
||||
.. Copyright (C) 2015 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Timelines
|
||||
*********
|
||||
|
||||
.. contents:: Table of content
|
||||
:local:
|
||||
|
||||
Concept
|
||||
=======
|
||||
|
||||
From an user point of view
|
||||
--------------------------
|
||||
|
||||
Chill has two objectives :
|
||||
|
||||
* make the administrative tasks more lightweight ;
|
||||
* help social workers to have all information they need to work
|
||||
|
||||
To reach this second objective, Chill provides a special view: **timeline**. On a timeline view, information is gathered and shown on a single page, from the most recent event to the oldest one.
|
||||
|
||||
The information gathered is linked to a *context*. This *context* may be, for instance :
|
||||
|
||||
* a person : events linked to this person are shown on the page ;
|
||||
* a center: events linked to a center are shown. They may concern different peoples ;
|
||||
* ...
|
||||
|
||||
In other word, the *context* is the kind of argument that will be used in the event's query.
|
||||
|
||||
Let us recall that only the data the user has allowed to see should be shown.
|
||||
|
||||
.. seealso::
|
||||
|
||||
`The issue where the subject was first discussed <https://redmine.champs-libres.coop/issues/224>`_
|
||||
|
||||
|
||||
For developers
|
||||
--------------
|
||||
|
||||
The `Main` bundle provides interfaces and services to help to build timelines.
|
||||
|
||||
If a bundle wants to *push* information in a timeline, it should be create a service which implements `Chill\MainBundle\Timeline\TimelineProviderInterface`, and tag is with `chill.timeline` and arguments defining the supported context (you may use multiple `chill.timeline` tags in order to support multiple context with a single service/class).
|
||||
|
||||
If a bundle wants to provide a new context for a timeline, the service `chill.main.timeline_builder` will helps to gather timeline's services supporting the defined context, and run queries across the models.
|
||||
|
||||
.. _understanding-queries :
|
||||
|
||||
Understanding queries
|
||||
^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
Due to the fact that timelines should show only the X last events from Y differents tables, queries for a timeline may consume a lot of resources: at first on the database, and then on the ORM part, which will have to deserialize DB data to PHP classes, which may not be used if they are not part of the "last X events".
|
||||
|
||||
To avoid such load on database, the objects are queried in two steps :
|
||||
|
||||
1. An UNION request which gather the last X events, ordered by date. The data retrieved are the ID, the date, and a string key: a type. This type discriminates the data type.
|
||||
2. The PHP objects are queried by ID, the type helps the program to link id with the kind of objects.
|
||||
|
||||
Those methods should ensure that only X PHP objects will be gathered and build by the ORM.
|
||||
|
||||
What does the master timeline builder service ?
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
When the service `chill.main.timeline_builder` is instanciated, the service is informed of each service taggued with `chill.timeline` tags. Then,
|
||||
|
||||
1. The service build an UNION query by assembling column and tables names provided by the `fetchQuery` result ;
|
||||
2. The UNION query is run, the result contains an id and a type for each row (see :ref:`above <understanding-queries>`)
|
||||
3. The master service gather all id with the same type. Then he searches for the `chill.timeline`'s service which will be able to get the entities. Then, the entities will be fetched using the `fetchEntities` function. All entities are gathered in one query ;
|
||||
4. The information to render entities in HTML is gathered by passing entity, one by one, on `getEntityTemplate` function.
|
||||
|
||||
Pushing events to a timeline
|
||||
=============================
|
||||
|
||||
To push events on a timeline :
|
||||
|
||||
1. Create a class which implements `Chill\MainBundle\Timeline\TimelineProviderInterface` ;
|
||||
2. Define the class as a service, and tag the service with `chill.timeline`, and define the context associated with this timeline (you may add multiple tags for different contexts).
|
||||
|
||||
Implementing the TimelineProviderInterface
|
||||
------------------------------------------
|
||||
|
||||
The has the following signature :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\MainBundle\Timeline;
|
||||
|
||||
interface TimelineProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @param string $context
|
||||
* @param mixed[] $args the argument to the context.
|
||||
* @return string[]
|
||||
* @throw \LogicException if the context is not supported
|
||||
*/
|
||||
public function fetchQuery($context, array $args);
|
||||
|
||||
/**
|
||||
* Indicate if the result type may be handled by the service
|
||||
*
|
||||
* @param string $type the key present in the SELECT query
|
||||
* @return boolean
|
||||
*/
|
||||
public function supportsType($type);
|
||||
|
||||
/**
|
||||
* fetch entities from db into an associative array. The keys **MUST BE**
|
||||
* the id
|
||||
*
|
||||
* All ids returned by all SELECT queries
|
||||
* (@see TimeLineProviderInterface::fetchQuery) and with the type
|
||||
* supported by the provider (@see TimelineProviderInterface::supportsType)
|
||||
* will be passed as argument.
|
||||
*
|
||||
* @param array $ids an array of id
|
||||
* @return mixed[] an associative array of entities, with id as key
|
||||
*/
|
||||
public function getEntities(array $ids);
|
||||
|
||||
/**
|
||||
* return an associative array with argument to render the entity
|
||||
* in an html template, which will be included in the timeline page
|
||||
*
|
||||
* The result must have the following key :
|
||||
*
|
||||
* - `template` : the template FQDN
|
||||
* - `template_data`: the data required by the template
|
||||
*
|
||||
*
|
||||
* Example:
|
||||
*
|
||||
* ```
|
||||
* array(
|
||||
* 'template' => 'ChillMyBundle:timeline:template.html.twig',
|
||||
* 'template_data' => array(
|
||||
* 'accompanyingPeriod' => $entity,
|
||||
* 'person' => $args['person']
|
||||
* )
|
||||
* );
|
||||
* ```
|
||||
*
|
||||
* `$context` and `$args` are defined by the bundle which will call the timeline
|
||||
* rendering.
|
||||
*
|
||||
* @param type $entity
|
||||
* @param type $context
|
||||
* @param array $args
|
||||
* @return mixed[]
|
||||
* @throws \LogicException if the context is not supported
|
||||
*/
|
||||
public function getEntityTemplate($entity, $context, array $args);
|
||||
|
||||
}
|
||||
|
||||
|
||||
The `fetchQuery` function
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
The fetchQuery function help to build the UNION query to gather events. This function should return an associative array MUST have the following key :
|
||||
|
||||
* `id` : the name of the id column
|
||||
* `type`: a string to indicate the type
|
||||
* `date`: the name of the datetime column, used to order entities by date
|
||||
* `FROM` (in capital) : the FROM clause. May contains JOIN instructions
|
||||
|
||||
Those key are optional:
|
||||
|
||||
* `WHERE` (in capital) : the WHERE clause.
|
||||
|
||||
Where relevant, the data must be quoted to avoid SQL injection.
|
||||
|
||||
`$context` and `$args` are defined by the bundle which will call the timeline rendering. You may use them to build a different query depending on this context.
|
||||
|
||||
For instance, if the context is `'person'`, the args will be this array :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
array(
|
||||
'person' => $person //a \Chill\PersonBundle\Entity\Person entity
|
||||
);
|
||||
|
||||
You should find in the bundle documentation which contexts are arguments the bundle defines.
|
||||
|
||||
.. note::
|
||||
|
||||
We encourage to use `ClassMetaData` to define column names arguments. If you change your column names, changes will be reflected automatically during the execution of your code.
|
||||
|
||||
Example of an implementation :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\ReportBundle\Timeline;
|
||||
|
||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* Provide report for inclusion in timeline
|
||||
*
|
||||
* @author Julien Fastré <julien.fastre@champs-libres.coop>
|
||||
* @author Champs Libres <info@champs-libres.coop>
|
||||
*/
|
||||
class TimelineReportProvider implements TimelineProviderInterface
|
||||
{
|
||||
|
||||
/**
|
||||
*
|
||||
* @var EntityManager
|
||||
*/
|
||||
protected $em;
|
||||
|
||||
public function __construct(EntityManager $em)
|
||||
{
|
||||
$this->em = $em;
|
||||
}
|
||||
|
||||
public function fetchQuery($context, array $args)
|
||||
{
|
||||
$this->checkContext($context);
|
||||
|
||||
$metadata = $this->em->getClassMetadata('ChillReportBundle:Report');
|
||||
|
||||
return array(
|
||||
'id' => $metadata->getColumnName('id'),
|
||||
'type' => 'report',
|
||||
'date' => $metadata->getColumnName('date'),
|
||||
'FROM' => $metadata->getTableName(),
|
||||
'WHERE' => sprintf('%s = %d',
|
||||
$metadata
|
||||
->getAssociationMapping('person')['joinColumns'][0]['name'],
|
||||
$args['person']->getId())
|
||||
);
|
||||
}
|
||||
|
||||
//....
|
||||
|
||||
|
||||
}
|
||||
|
||||
The `supportsType` function
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This function indicate to the master `chill.main.timeline_builder` service (which orchestrate the build of UNION queries) that the service supports the type indicated in the result's array of the `fetchQuery` function.
|
||||
|
||||
The implementation of our previous example will be :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
|
||||
namespace Chill\ReportBundle\Timeline;
|
||||
|
||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class TimelineReportProvider implements TimelineProviderInterface
|
||||
{
|
||||
|
||||
//...
|
||||
|
||||
/**
|
||||
*
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function supportsType($type)
|
||||
{
|
||||
return $type === 'report';
|
||||
}
|
||||
|
||||
//...
|
||||
}
|
||||
|
||||
The `getEntities` function
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is where the service must fetch entities from database and return them to the master service.
|
||||
|
||||
The results **must be** an array where the id given by the UNION query (remember `fetchQuery`).
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\ReportBundle\Timeline;
|
||||
|
||||
use Chill\MainBundle\Timeline\TimelineProviderInterface;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
class TimelineReportProvider implements TimelineProviderInterface
|
||||
{
|
||||
|
||||
public function getEntities(array $ids)
|
||||
{
|
||||
$reports = $this->em->getRepository('ChillReportBundle:Report')
|
||||
->findBy(array('id' => $ids));
|
||||
|
||||
$result = array();
|
||||
foreach($reports as $report) {
|
||||
$result[$report->getId()] = $report;
|
||||
}
|
||||
|
||||
return $result;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
The `getEntityTemplate` function
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This is where the master service will collect information to render the entity.
|
||||
|
||||
The result must be an associative array with :
|
||||
|
||||
- **template** is the FQDN of the template ;
|
||||
- **template_data** is an associative array where keys are the variables'names for this template, and values are the values.
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
array(
|
||||
'template' => 'ChillMyBundle:timeline:template.html.twig',
|
||||
'template_data' => array(
|
||||
'period' => $entity,
|
||||
'person' => $args['person']
|
||||
)
|
||||
);
|
||||
|
||||
The template must, obviously, exists. Example :
|
||||
|
||||
.. code-block:: jinja
|
||||
|
||||
<p><i class="fa fa-folder-open"></i> {{ 'An accompanying period is opened for %person% on %date%'|trans({'%person%': person, '%date%': period.dateOpening|localizeddate('long', 'none') } ) }}</p>
|
||||
|
||||
|
||||
Create a timeline with his own context
|
||||
======================================
|
||||
|
||||
You have to create a Controller which will execute the service `chill.main.timeline_builder`. Using the `Chill\MainBundle\Timeline\TimelineBuilder::getTimelineHTML` function, you will get an HTML representation of the timeline, which you may include with twig `raw` filter.
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\Controller;
|
||||
|
||||
use Symfony\Component\HttpFoundation\Response;
|
||||
use Symfony\Component\HttpFoundation\Request;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
|
||||
class TimelinePersonController extends Controller
|
||||
{
|
||||
|
||||
public function personAction(Request $request, $person_id)
|
||||
{
|
||||
$person = $this->getDoctrine()
|
||||
->getRepository('ChillPersonBundle:Person')
|
||||
->find($person_id);
|
||||
|
||||
if ($person === NULL) {
|
||||
throw $this->createNotFoundException();
|
||||
}
|
||||
|
||||
return $this->render('ChillPersonBundle:Timeline:index.html.twig', array
|
||||
(
|
||||
'timeline' => $this->get('chill.main.timeline_builder')
|
||||
->getTimelineHTML('person', array('person' => $person)),
|
||||
'person' => $person
|
||||
)
|
||||
);
|
||||
}
|
||||
|
||||
}
|
73
docs/source/development/useful-snippets.rst
Normal file
@ -0,0 +1,73 @@
|
||||
|
||||
|
||||
|
||||
|
||||
Useful snippets
|
||||
###############
|
||||
|
||||
Dependency Injection
|
||||
********************
|
||||
|
||||
Configure route automatically
|
||||
=============================
|
||||
|
||||
Add the route for the current bundle automatically on the main app.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\MyBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
|
||||
|
||||
class ChillMyExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
// ...
|
||||
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$this->prependRoutes($container);
|
||||
|
||||
}
|
||||
|
||||
public function prependRoutes(ContainerBuilder $container)
|
||||
{
|
||||
//add routes for custom bundle
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'routing' => array(
|
||||
'resources' => array(
|
||||
'@ChillMyBundle/Resources/config/routing.yml'
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
|
||||
|
||||
Security
|
||||
********
|
||||
|
||||
Get the circles a user can reach
|
||||
================================
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
$authorizationHelper = $this->get('chill.main.security.authorization.helper');
|
||||
$circles = $authorizationHelper
|
||||
->getReachableCircles(
|
||||
$this->getUser(), # from a controller
|
||||
new Role('CHILL_ROLE'),
|
||||
$center
|
||||
);
|
||||
|
||||
|
||||
Controller
|
||||
**********
|
||||
|
||||
Secured controller for person
|
||||
=============================
|
||||
|
||||
.. literalinclude:: useful-snippets/controller-secured-for-person.php
|
||||
:language: php
|
@ -0,0 +1,55 @@
|
||||
<?php
|
||||
|
||||
namespace Chill\HealthBundle\Controller;
|
||||
|
||||
use Chill\HealthBundle\Security\Authorization\ConsultationVoter;
|
||||
use Symfony\Bundle\FrameworkBundle\Controller\Controller;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
|
||||
class ConsultationController extends Controller
|
||||
{
|
||||
/**
|
||||
*
|
||||
* @param int $id personId
|
||||
* @return \Symfony\Component\HttpFoundation\Response
|
||||
* @throws type
|
||||
*/
|
||||
public function listAction($id)
|
||||
{
|
||||
/* @var $person \Chill\PersonBundle\Entity\Person */
|
||||
$person = $this->get('chill.person.repository.person')
|
||||
->find($id);
|
||||
|
||||
if ($person === null) {
|
||||
throw $this->createNotFoundException("The person is not found");
|
||||
}
|
||||
|
||||
$this->denyAccessUnlessGranted(PersonVoter::SEE, $person);
|
||||
|
||||
/* @var $authorizationHelper \Chill\MainBundle\Security\Authorization\AuthorizationHelper */
|
||||
$authorizationHelper = $this->get('chill.main.security.'
|
||||
. 'authorization.helper');
|
||||
|
||||
$circles = $authorizationHelper->getReachableCircles(
|
||||
$this->getUser(),
|
||||
new Role(ConsultationVoter::SEE),
|
||||
$person->getCenter()
|
||||
);
|
||||
|
||||
// create a query which take circles into account
|
||||
$consultations = $this->getDoctrine()->getManager()
|
||||
->createQuery('SELECT c FROM ChillHealthBundle:Consultation c '
|
||||
. 'WHERE c.patient = :person AND c.circle IN(:circles) '
|
||||
. 'ORDER BY c.date DESC')
|
||||
->setParameter('person', $person)
|
||||
->setParameter('circles', $circles)
|
||||
->getResult();
|
||||
|
||||
return $this->render('ChillHealthBundle:Consultation:list.html.twig', array(
|
||||
'person' => $person,
|
||||
'consultations' => $consultations
|
||||
));
|
||||
}
|
||||
}
|
||||
|
77
docs/source/development/user-interface/css-classes.rst
Normal file
@ -0,0 +1,77 @@
|
||||
.. Copyright (C) 2016 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
CSS classes and mixins
|
||||
######################
|
||||
|
||||
The stylesheet are based on the framework `ScratchCSS <https://github.com/Champs-Libres/ScratchCSS>`_.
|
||||
|
||||
We added some useful classes and mixins for the Chill usage.
|
||||
|
||||
CSS Classes
|
||||
************
|
||||
|
||||
|
||||
Statement "empty data"
|
||||
======================
|
||||
|
||||
CSS Selector
|
||||
:code:`.chill-no-data-statement`
|
||||
In which case will you use this selector ?
|
||||
When a list is empty, and a message fill the list to inform that the data is empty
|
||||
Example usage
|
||||
.. code-block:: html+jinja
|
||||
|
||||
<span class="chill-no-data-statement">{{ 'No reason associated'|trans }}</span>
|
||||
|
||||
|
||||
Quotation of user text
|
||||
=======================
|
||||
|
||||
CSS Selector
|
||||
:code:`blockquote.chill-user-quote`
|
||||
In which case will you use this selector ?
|
||||
When you quote text that were filled by the user in a form.
|
||||
Example usage
|
||||
.. code-block:: html+jinja
|
||||
|
||||
<blockquote class="chill-user-quote">{{ entity.remark|nl2br }}</blockquote>
|
||||
|
||||
Boxes
|
||||
=====
|
||||
|
||||
CSS Selector
|
||||
:code:`chill__box`
|
||||
In which case will you use this selector ?
|
||||
When displaying some data in a nice box
|
||||
Example usage
|
||||
.. code-block:: html+twig
|
||||
|
||||
<span class="chill__box green">A nice box with green background</span>
|
||||
<span class="chill__box red">A nice box with red background</span>
|
||||
|
||||
|
||||
|
||||
Mixins
|
||||
******
|
||||
|
||||
|
||||
Entity decorator
|
||||
=================
|
||||
|
||||
Mixin
|
||||
:code:`@mixin entity($background-color, $color: white)`
|
||||
In which case including this mixin ?
|
||||
When you create a `sticker`, a sort of label to represent a text in a way that the user can associate immediatly with a certain type of class / entity.
|
||||
Example usage
|
||||
.. code-block:: sass
|
||||
|
||||
span.entity.entity-activity.activity-reason {
|
||||
@include entity($chill-pink, white);
|
||||
}
|
261
docs/source/development/user-interface/js-functions.rst
Normal file
@ -0,0 +1,261 @@
|
||||
.. Copyright (C) 2016 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
Javascript functions
|
||||
####################
|
||||
|
||||
Some function may be useful to manipulate elements on the page.
|
||||
|
||||
Show-hide elements according to a form state
|
||||
*********************************************
|
||||
|
||||
The module ``ShowHide`` will allow you to show/hide part of your page using a specific test.
|
||||
|
||||
This must be use inside a javascript module.
|
||||
|
||||
Usage
|
||||
=====
|
||||
|
||||
In this module, the module will listen to all input given in the ``container_from`` div, and will show or hide the content of the ``container_target`` according to the result of the ``test`` function.
|
||||
|
||||
.. code-block:: html+twig
|
||||
|
||||
<div id="container_from">
|
||||
{{ form_row(form.accompagnementRQTHDate) }}
|
||||
</div>
|
||||
|
||||
<div id="container_target">
|
||||
{{ form_row(form.accompagnementComment) }}
|
||||
</div>
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
import { ShowHide } from 'ShowHide/show_hide.js';
|
||||
|
||||
var
|
||||
from = document.getElementById("container_from"),
|
||||
target = document.getElementById("container_target")
|
||||
;
|
||||
|
||||
new ShowHide({
|
||||
froms: [from], // the value of from should be an iterable
|
||||
container: [target], // the value of container should be an iterable
|
||||
test: function(froms, event) {
|
||||
// iterate over each element of froms
|
||||
for (let f of froms.values()) {
|
||||
// get all input inside froms
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
if (input.value === 'autre') {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
Once instantiated, the class ``ShowHide`` will:
|
||||
|
||||
1. get all input from each element inside the ``froms`` values
|
||||
2. attach an event listener (by default, ``change``) to each input inside each entry in ``froms``
|
||||
3. each time the event is fired, launch the function ``test``
|
||||
4. show the element in the container given in ``container``, if the result of ``test`` is true, or hide them otherwise.
|
||||
|
||||
The test is also launched when the page is loaded.
|
||||
|
||||
Show/hide while the user enter data: using the ``input`` event
|
||||
==============================================================
|
||||
|
||||
One can force to use another event on the input elements, instead of the default ``'change'`` event.
|
||||
|
||||
For achieving this, use the `event_name` option.
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
new ShowHide({
|
||||
froms: froms,
|
||||
test: test_function,
|
||||
container: containers ,
|
||||
// using this option, we use the event `input` instead of `change`
|
||||
event_name: 'input'
|
||||
});
|
||||
|
||||
Examples
|
||||
--------
|
||||
|
||||
.. literalinclude:: js-functions/show_hide.js
|
||||
:language: javascript
|
||||
|
||||
|
||||
Using Show/Hide in collections forms
|
||||
====================================
|
||||
|
||||
Using show / hide in collection forms implies:
|
||||
|
||||
* to launch show/hide manually for each entry when the page is loaded ;
|
||||
* to catch when an entry is added to the form ;
|
||||
|
||||
As the show/hide is started manually and not on page load, we add the option ``load_event: null`` to the options:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [ from ],
|
||||
container: [ container ],
|
||||
test: my_test_function
|
||||
});
|
||||
|
||||
.. note::
|
||||
|
||||
When using ``load_event: null`` inside the options, the value of event will be ``null`` as second argument for the test function.
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
my_test_function(froms, event) {
|
||||
// event will be null on first launch
|
||||
}
|
||||
|
||||
Example usage: here, we would like to catch for element inside a CV form, where the user may add multiple formation entries.
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
import { ShowHide } from 'ShowHide/show_hide.js';
|
||||
|
||||
// we factorize the creation of show hide element in this function.
|
||||
var make_show_hide = function(entry) {
|
||||
let
|
||||
obtained = entry.querySelector('[data-diploma-obtained]'),
|
||||
reconnue = entry.querySelector('[data-diploma-reconnue]')
|
||||
;
|
||||
new ShowHide({
|
||||
load_event: null,
|
||||
froms: [ obtained ],
|
||||
container: [ reconnue ],
|
||||
test: my_test_function
|
||||
});
|
||||
};
|
||||
|
||||
// this code is fired when an entry is added on the page
|
||||
window.addEventListener('collection-add-entry', function(e) {
|
||||
// if the form contains multiple collection, we filter them here:
|
||||
if (e.detail.collection.dataset.collectionName === 'formations') {
|
||||
make_show_hide(e.detail.entry);
|
||||
}
|
||||
});
|
||||
|
||||
// on page load, we create a show/hide
|
||||
window.addEventListener('load', function(_e) {
|
||||
let
|
||||
formations = document.querySelectorAll('[data-formation-entry]')
|
||||
;
|
||||
|
||||
for (let f of formations.values()) {
|
||||
make_show_hide(f);
|
||||
}
|
||||
});
|
||||
|
||||
Handling encapsulated show/hide elements
|
||||
========================================
|
||||
|
||||
This module allow to handle encapsulated show/hide elements. For instance :
|
||||
|
||||
* in a first checkbox list, a second checkbox list is shown if some element is checked ;
|
||||
* in this second checkbox list, a third input is shown if some element is checked inside the second checkbox list.
|
||||
|
||||
As a consequence, if the given element in the first checkbox list is unchecked, the third input must also be hidden.
|
||||
|
||||
Example: when a situation professionnelle is ``en activite``, the second element ``type contrat`` must be shown if ``en_activite`` is checked. Inside ``type_contrat``, ``type_contrat_aide`` should be shown when ``contrat_aide`` is checked.
|
||||
|
||||
.. code-block:: html
|
||||
|
||||
<div id="situation_prof">
|
||||
<input type="radio" name="situationProfessionnelle" value="" checked="checked" />
|
||||
<input type="radio" name="situationProfessionnelle" value="sans_emploi" />
|
||||
<input type="radio" name="situationProfessionnelle" value="en_activite" />
|
||||
</div>
|
||||
|
||||
|
||||
<div id="type_contrat">
|
||||
<input type="checkbox" name="typeContrat[]" value="cdd" />
|
||||
<input type="checkbox" name="typeContrat[]" value="cdi" />
|
||||
<input type="checkbox" name="typeContrat[]" value="contrat_aide" />
|
||||
</div>
|
||||
|
||||
<div id="type_contrat_aide">
|
||||
<input type="text" name="typeContratAide" />
|
||||
</div>
|
||||
|
||||
The JS code will be:
|
||||
|
||||
.. code-block:: javascript
|
||||
|
||||
import { ShowHide } from 'ShowHide/show_hide.js';
|
||||
// we search for the element within the DOM
|
||||
// NOTE: all the elements should be searched before instanciating the showHides.
|
||||
// if not, the elements **may** have disappeared from the DOM
|
||||
|
||||
var
|
||||
situation_prof = document.getElementById('situation_prof'),
|
||||
type_contrat = document.getElementById('type_contrat'),
|
||||
type_contrat_aide = document.getElementById('type_contrat_aide'),
|
||||
;
|
||||
|
||||
// the first show/hide will apply on situation_prof
|
||||
new ShowHide({
|
||||
// the id will help us to keep a track of the element
|
||||
id: 'situation_prof_type_contrat',
|
||||
froms: [situation_prof],
|
||||
container: [type_contrat],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
if (input.value === 'en_activite') {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// the show/hide will apply on "contrat aide"
|
||||
var show_hide_contrat_aide = new ShowHide({
|
||||
froms: [type_contrat],
|
||||
container: [type_contrat_aide],
|
||||
test: function(froms) {
|
||||
for (let f of froms.values()) {
|
||||
for (let input of f.querySelectorAll('input').values()) {
|
||||
if (input.value === 'contrat_aide') {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
});
|
||||
|
||||
// we handle here the case when the first show-hide is changed: the third input must also disappears
|
||||
window.addEventListener('show-hide-hide', function (e) {
|
||||
if (e.detail.id = 'situation_prof_type_contrat') {
|
||||
// we force the 3rd element to disappears
|
||||
show_hide_contrat_aide.forceHide();
|
||||
}
|
||||
});
|
||||
|
||||
// when the first show-hide is changed, it makes appears the second one.
|
||||
// we check here that the second show-hide is processed.
|
||||
window.addEventListener('show-hide-show', function (e) {
|
||||
if (e.detail.id = 'situation_prof_type_contrat') {
|
||||
show_hide_contrat_aide.forceCompute();
|
||||
}
|
||||
});
|
@ -0,0 +1,39 @@
|
||||
import { ShowHide } from 'ShowHide/show_hide.js';
|
||||
|
||||
var
|
||||
div_accompagnement = document.getElementById("form_accompagnement"),
|
||||
div_accompagnement_comment = document.getElementById("form_accompagnement_comment"),
|
||||
div_caf_id = document.getElementById("cafId"),
|
||||
div_caf_inscription_date = document.getElementById("cafInscriptionDate"),
|
||||
;
|
||||
|
||||
// let show/hide the div_accompagnement_comment if the input with value `'autre'` is checked
|
||||
new ShowHide({
|
||||
"froms": [div_accompagnement],
|
||||
"test": function(froms, event) {
|
||||
for (let el of froms.values()) {
|
||||
for (let input of el.querySelectorAll('input').values()) {
|
||||
if (input.value === 'autre') {
|
||||
return input.checked;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
},
|
||||
"container": [div_accompagnement_comment]
|
||||
});
|
||||
|
||||
// let show the date input only if the the id is filled
|
||||
new ShowHide({
|
||||
froms: [ div_caf_id ],
|
||||
test: function(froms, event) {
|
||||
for (let el of froms.values()) {
|
||||
return el.querySelector("input").value !== "";
|
||||
}
|
||||
},
|
||||
container: [ div_caf_inscription_date ],
|
||||
// using this option, we use the event `input` instead of `change`
|
||||
event_name: 'input'
|
||||
});
|
||||
|
225
docs/source/development/user-interface/layout-template-usage.rst
Normal file
@ -0,0 +1,225 @@
|
||||
.. Copyright (C) 2015 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
|
||||
Layout / Template usage
|
||||
#######################
|
||||
|
||||
We recommand the use of the existing layouts to ensure the consistency of the design. This section explains the different templates and how to use it.
|
||||
|
||||
The layouts are twig templates.
|
||||
|
||||
Twig templating helper
|
||||
======================
|
||||
|
||||
`chill_print_or_message`
|
||||
------------------------
|
||||
|
||||
Print a value or use a default template if the value is empty.
|
||||
|
||||
The template can be customized.
|
||||
|
||||
Two default templates are registered:
|
||||
|
||||
- :code:`default`, do not decorate the value ;
|
||||
- :code:`blockquote`: wrap the value into a blockquote if exists
|
||||
|
||||
.. code-block:: html+twig
|
||||
|
||||
{{ "This is a message"|chill_print_or_message("No message") }}
|
||||
<!-- will print "This is a message" -->
|
||||
|
||||
{{ ""|chill_print_or_message("No message")}}
|
||||
<!-- will print <span class="chill-no-data-statement">No message</span> -->
|
||||
|
||||
{{ "This is a comment\n with multiples lines"|chill_print_or_message("No comment", 'blockquote') }}
|
||||
<!-- will print <blockquote class="chill-user-quote">This is a comment<br/>with multiples lines</blockquote> -->
|
||||
|
||||
When customizing the template, two arguments are passed to the template:
|
||||
|
||||
- :code:`value`: the actual value ;
|
||||
- :code:`message`: the message, given as argument
|
||||
|
||||
Routing with return path
|
||||
------------------------
|
||||
|
||||
Three twig function are available for creating routes and handling "return path".
|
||||
|
||||
**Rationale**: When building a "CRUD" (CReate, Update, Delete of an entity), you would like to allow people to go back on some custom cancel page when coming for another place of an application. For instance, if you are in the timeline and show an activity, you would like that the user go back to the timeline when pressing the "return" button at the bottom of the page, instead of going back to the "activity list" page.
|
||||
|
||||
Using those function, a :code:`returnPath` parameter will be added in the path generated. It will be used instead of the default one in the subsequente pages.
|
||||
|
||||
- :code:`chill_path_add_return_path(name, parameters = [], relative = false)`: will create a path with current page as return path (users will go back to the current page on the next page) ;
|
||||
- :code:`chill_return_path_or(name, parameters = [], relative = false)`: will create a path to the return path if present, or build the path according to the given parameters ;
|
||||
- :code:`chill_path_forward_return_path(name, parameters = [], relative = false)`: will create a path and adding the return path that is present for the current page, *forwarding* the return path to the next page. This is useful if you are on a "show" page with a return path (by instance, the "timeline" page), you place a link to the *edit* page and want users to go back to the "timeline" page on the edit page.
|
||||
|
||||
|
||||
- :code:`chill_return_path_or`:
|
||||
|
||||
|
||||
Organisation of the layouts
|
||||
===========================
|
||||
|
||||
ChillMainBundle::layout.html.twig
|
||||
---------------------------------
|
||||
|
||||
This is the base layout. It includes the most import css / js files. It display a page with
|
||||
|
||||
* a horizontal navigation menu
|
||||
* a place for content
|
||||
* a footer
|
||||
|
||||
|
||||
The layout containts blocks, that are :
|
||||
|
||||
* title
|
||||
|
||||
* to display title
|
||||
|
||||
* css
|
||||
|
||||
* where to add some custom css
|
||||
|
||||
* navigation_section_menu
|
||||
|
||||
* place where to insert the section menu in the navigation menu (by default the navigation menu is inserted)
|
||||
|
||||
* navigation_search_bar
|
||||
|
||||
* place where to insert a search bar in the navigation menu (by default the search bar is inserted)
|
||||
|
||||
* top_banner
|
||||
|
||||
* place where to display a banner below the navigation menu (this place is use to display the details of the person)
|
||||
|
||||
* sublayout_containter
|
||||
|
||||
* place between the header and the footer that can be used to create a new layout (with vertical menu for example)
|
||||
|
||||
* content
|
||||
|
||||
* place where to display the content (flash message are included outside of this block)
|
||||
|
||||
* js
|
||||
|
||||
* where to add some custom javascript
|
||||
|
||||
|
||||
ChillMainBundle::layoutWithVerticalMenu.html.twig
|
||||
-------------------------------------------------
|
||||
|
||||
This layout extends `ChillMainBundle::layout.html.twig`. It replaces the block `layout_content` and divides this block for displaying a vertical menu and some content.
|
||||
|
||||
It proposes 2 new blocks :
|
||||
|
||||
* layout_wvm_content
|
||||
|
||||
* where to display the page content
|
||||
|
||||
* vertical_menu_content
|
||||
|
||||
* where to place the vertical menu
|
||||
|
||||
|
||||
ChillMainBundle::Admin/layout.html.twig
|
||||
---------------------------------------
|
||||
|
||||
This layout extends `ChillMainBundle::layout.html.twig`. It hides the search bar, remplaces the `section menu` with the `admin section menu`.
|
||||
|
||||
It proposes a new block :
|
||||
|
||||
* admin_content
|
||||
|
||||
* where to display the admin content
|
||||
|
||||
|
||||
ChillMainBundle::Admin/layoutWithVerticalMenu.html.twig
|
||||
-------------------------------------------------------
|
||||
|
||||
This layout extends `ChillMainBundle::layoutWithVerticalMenu.html.twig`. It do the same changes than `ChillMainBundle::Admin/layout.html.twig` : hiding the search bar, remplacing the `section menu` with the `admin section menu`.
|
||||
|
||||
It proposes a new block :
|
||||
|
||||
* admin_content
|
||||
|
||||
* where to display the admin content
|
||||
|
||||
ChillPersonBundle::layout.html.twig
|
||||
-----------------------------------
|
||||
|
||||
This layout extend `ChillMainBundle::layoutWithVerticalMenu.html.twig` add the person details in the block `top_banner`, set the menu `person` as the vertical menu.
|
||||
|
||||
It proposes 1 new block :
|
||||
|
||||
* personcontent
|
||||
|
||||
* where to display the information of the person
|
||||
|
||||
|
||||
ChillMainBundle::Export/layout.html.twig
|
||||
----------------------------------------
|
||||
|
||||
This layout extends `ChillMainBundle::layoutWithVerticalMenu.html.twig` and set the menu `export` as the vertical menu.
|
||||
|
||||
It proposes 1 new block :
|
||||
|
||||
* export_content
|
||||
|
||||
* where to display the content of the export
|
||||
|
||||
Useful template and helpers
|
||||
===========================
|
||||
|
||||
Macros
|
||||
------
|
||||
|
||||
Every bundle may bring their own macro to print resources with uniformized styles.
|
||||
|
||||
See :
|
||||
|
||||
- :ref:`Macros in person bundle <person-bundle-macros>` ;
|
||||
- :ref:`Macros in activity bundle <activity-bundle-macros>` ;
|
||||
- :ref:`Macros in group bundle <group-bundle-macros>` ;
|
||||
- :ref:`Macros in main bundle <main-bundle-macros>` ;
|
||||
|
||||
Templates
|
||||
---------
|
||||
|
||||
ChillMainBundle::Util:confirmation_template.html.twig
|
||||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
||||
|
||||
This template show a confirmation template before making dangerous things. You can add your own message and title, or define those message by yourself in another template.
|
||||
|
||||
The accepted parameters are :
|
||||
|
||||
- `title` (string) a title for the page. Not mandatory (it won't be rendered if not defined)
|
||||
- `confirm_question` (string) a confirmation question. This question will not be translated into the template, and may be printed as raw. Not mandatory (it won't be rendered if not defined)
|
||||
- `form` : (:class:`Symfony\Component\Form\FormView`) a form wich **must** contains an input named `submit`, which must be a :class:`Symfony\Component\Form\Extension\Core\Type\SubmitType`. Mandatory
|
||||
- `cancel_route` : (string) the name of a route if the user want to cancel the action
|
||||
- `cancel_parameters` (array) the parameters for the route defined in `cancel_route`
|
||||
|
||||
|
||||
Usage :
|
||||
|
||||
|
||||
.. code-block:: html+twig
|
||||
|
||||
{{ include('ChillMainBundle:Util:confirmation_template.html.twig',
|
||||
{
|
||||
# a title, not mandatory
|
||||
'title' : 'Remove membership'|trans,
|
||||
# a confirmation question, not mandatory
|
||||
'confirm_question' : 'Are you sure you want to remove membership ?'|trans
|
||||
# a route for "cancel" button (mandatory)
|
||||
'cancel_route' : 'chill_group_membership_by_person',
|
||||
# the parameters for 'cancel' route (default to {} )
|
||||
'cancel_parameters' : { 'person_id' : membership.person.id },
|
||||
# the form which will send the deletion. This form
|
||||
# **must** contains a SubmitType
|
||||
'form' : form
|
||||
} ) }}
|
333
docs/source/development/user-interface/widgets.rst
Normal file
@ -0,0 +1,333 @@
|
||||
.. Copyright (C) 2016 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Widgets
|
||||
##############################################
|
||||
|
||||
Rationale
|
||||
=========
|
||||
|
||||
Widgets are useful if you want to publish content on a page provided by another bundle.
|
||||
|
||||
|
||||
Examples :
|
||||
|
||||
- you want to publish a list of people on the homepage ;
|
||||
- you may want to show the group belonging (see :ref:`group-bundle`) below of the vertical menu, only if the bundle is installed.
|
||||
|
||||
The administrator of the chill instance may configure the presence of widget. Although, some widget are defined by default (see :ref:`declaring-widget-by-default`).
|
||||
|
||||
Concepts
|
||||
========
|
||||
|
||||
A bundle may define *place(s)* where a widget may be rendered.
|
||||
|
||||
In a single *place*, zero, one or more *widget* may be displayed.
|
||||
|
||||
Some *widget* may require some *configuration*, and some does not require any configuration.
|
||||
|
||||
Example:
|
||||
|
||||
=========================================== ======== ============================= =======================================
|
||||
Use case place place defined by... widget provided by...
|
||||
=========================================== ======== ============================= =======================================
|
||||
Publishing a list of people on the homepage homepage defined by :ref:`main-bundle` widget provided by :ref:`person-bundle`
|
||||
=========================================== ======== ============================= =======================================
|
||||
|
||||
|
||||
|
||||
Creating a widget without configuration
|
||||
========================================
|
||||
|
||||
To add a widget, you should :
|
||||
|
||||
- define your widget, implementing :class:`Chill\MainBundle\Templating\Widget\WidgetInterface` ;
|
||||
- declare your widget with tag `chill_widget`.
|
||||
|
||||
|
||||
Define the widget class
|
||||
-----------------------
|
||||
|
||||
Define your widget class by implemeting :class:`Chill\MainBundle\Templating\Widget\WidgetInterface`.
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\PersonBundle\Widget;
|
||||
|
||||
use Chill\MainBundle\Templating\Widget\WidgetInterface;
|
||||
|
||||
|
||||
/**
|
||||
* Add a button "add a person"
|
||||
*
|
||||
*/
|
||||
class AddAPersonWidget implements WidgetInterface
|
||||
{
|
||||
public function render(
|
||||
\Twig_Environment $env,
|
||||
$place,
|
||||
array $context,
|
||||
array $config
|
||||
) {
|
||||
// this will render a link to the page "add a person"
|
||||
return $env->render("ChillPersonBundle:Widget:homepage_add_a_person.html.twig");
|
||||
}
|
||||
}
|
||||
|
||||
Arguments are :
|
||||
|
||||
- :code:`$env` the :class:`\Twig_Environment`, which you can use to render your widget ;
|
||||
- :code:`$place` a string representing the place where the widget is rendered ;
|
||||
- :code:`$context` the context given by the template ;
|
||||
- :code:`$config` the configuration which is, in this case, always an empty array (see :ref:`creating-a-widget-with-config`).
|
||||
|
||||
.. note::
|
||||
|
||||
The html returned by the :code:`render` function will be considered as html safe. You should strip html before returning it. See also `How to escape output in template <http://symfony.com/doc/current/templating/escaping.html>`_.
|
||||
|
||||
|
||||
Declare your widget
|
||||
-------------------
|
||||
|
||||
Declare your widget as a service and add it the tag :code:`chill_widget`:
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
service:
|
||||
chill_person.widget.add_person:
|
||||
class: Chill\PersonBundle\Widget\AddAPersonWidget
|
||||
tags:
|
||||
- { name: chill_widget, alias: add_person, place: homepage }
|
||||
|
||||
|
||||
The tag must contains those arguments :
|
||||
|
||||
- :code:`alias`: an alias, which will be used to reference the widget into the config
|
||||
- :code:`place`: a place where this widget is authorized
|
||||
|
||||
If you want your widget to be available on multiple places, you should add one tag with each place.
|
||||
|
||||
Conclusion
|
||||
----------
|
||||
|
||||
Once your widget is correctly declared, your widget should be available in configuration.
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
$ php app/console config:dump-reference chill_main
|
||||
# Default configuration for extension with alias: "chill_main"
|
||||
chill_main:
|
||||
[...]
|
||||
# register widgets on place "homepage"
|
||||
homepage:
|
||||
|
||||
# the ordering of the widget. May be a number with decimal
|
||||
order: ~ # Required, Example: 10.58
|
||||
|
||||
# the widget alias (see your installed bundles config). Possible values are (maybe incomplete) : person_list, add_person
|
||||
widget_alias: ~ # Required
|
||||
|
||||
If you want to add your widget by default, see :ref:`declaring-widget-by-default`.
|
||||
|
||||
.. _creating-a-widget-with-config:
|
||||
|
||||
Creating a widget **with** configuration
|
||||
========================================
|
||||
|
||||
You can declare some configuration with your widget, which allow administrators to add their own configuration.
|
||||
|
||||
To add some configuration, you will :
|
||||
|
||||
- declare a widget as defined above ;
|
||||
- optionnaly declare it as a service ;
|
||||
- add a widget factory, which will add configuration to the bundle which provide the place.
|
||||
|
||||
|
||||
Declare your widget class
|
||||
-------------------------
|
||||
|
||||
Declare your widget. You can use some configuration elements in your process, as used here :
|
||||
|
||||
.. literalinclude:: ./widgets/ChillPersonAddAPersonWidget.php
|
||||
:language: php
|
||||
|
||||
Declare your widget as a service
|
||||
--------------------------------
|
||||
|
||||
You can declare your widget as a service. Not tag is required, as the service will be defined by the :code:`Factory` during next step.
|
||||
|
||||
|
||||
.. code-block:: yaml
|
||||
|
||||
services:
|
||||
chill_person.widget.person_list:
|
||||
class: Chill\PersonBundle\Widget\PersonListWidget
|
||||
arguments:
|
||||
- "@chill.person.repository.person"
|
||||
- "@doctrine.orm.entity_manager"
|
||||
- "@chill.main.security.authorization.helper"
|
||||
- "@security.token_storage"
|
||||
# this widget is defined by the PersonListWidgetFactory
|
||||
|
||||
You can eventually skip this step and declare your service into the container through the factory (see above).
|
||||
|
||||
Declare your widget factory
|
||||
---------------------------
|
||||
|
||||
The widget factory must implements `Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface`. For your convenience, an :class:`Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory` will already implements some easy method.
|
||||
|
||||
.. literalinclude:: ./widgets/ChillPersonAddAPersonListWidgetFactory.php
|
||||
:language: php
|
||||
|
||||
.. note::
|
||||
You can declare your widget into the container by overriding the `createDefinition` method. By default, this method will return the already existing service definition with the id given by :code:`getServiceId`. But you can create or adapt programmatically the definition. `See the symfony doc on how to do it <http://symfony.com/doc/current/service_container/definitions.html#working-with-a-definition>`_.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
public function createDefinition(ContainerBuilder $containerBuilder, $place, $order, array $config)
|
||||
{
|
||||
$definition = new \Symfony\Component\DependencyInjection\Definition('my\Class');
|
||||
// create or adapt your definition here
|
||||
|
||||
return $definition;
|
||||
}
|
||||
|
||||
You must then register your factory into the :code:`Extension` class which provide the place. This is done in the :code: `Bundle` class.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
# Chill/PersonBundle/ChillPersonBundle.php
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Chill\PersonBundle\Widget\PersonListWidgetFactory;
|
||||
|
||||
class ChillPersonBundle extends Bundle
|
||||
{
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
|
||||
$container->getExtension('chill_main')
|
||||
->addWidgetFactory(new PersonListWidgetFactory());
|
||||
}
|
||||
}
|
||||
|
||||
.. _declaring-widget-by-default:
|
||||
|
||||
Declaring a widget by default
|
||||
=============================
|
||||
|
||||
Use the ability `to prepend configuration of other bundle <http://symfony.com/doc/current/bundles/prepend_extension.html>`_. A living example here :
|
||||
|
||||
.. literalinclude:: ./widgets/ChillPersonExtension.php
|
||||
:language: php
|
||||
|
||||
|
||||
Defining a place
|
||||
================
|
||||
|
||||
Add your place in template
|
||||
--------------------------
|
||||
|
||||
A place should be defined by using the :code:`chill_widget` function, which take as argument :
|
||||
|
||||
- :code:`place` (string) a string defining the place ;
|
||||
- :code:`context` (array) an array defining the context.
|
||||
|
||||
The context should be documented by the bundle. It will give some information about the context of the page. Example: if the page concerns a people, the :class:`Chill\PersonBundle\Entity\Person` class will be in the context.
|
||||
|
||||
Example :
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{# an empty context on homepage #}
|
||||
{{ chill_widget('homepage', {} }}
|
||||
|
||||
.. code-block:: html+jinja
|
||||
|
||||
{# defining a place 'right column' with the person currently viewed
|
||||
{{ chill_widget('right_column', { 'person' : person } }}
|
||||
|
||||
|
||||
Declare configuration for you place
|
||||
-----------------------------------
|
||||
|
||||
In order to let other bundle, or user, to define the widgets inside the given place, you should open a configuration. You can use the Trait :class:`Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait`, which provide the method `addWidgetConfiguration($place, ContainerBuilder $container)`.
|
||||
|
||||
Example :
|
||||
|
||||
.. literalinclude:: ./widgets/ChillMainConfiguration.php
|
||||
:language: php
|
||||
:emphasize-lines: 17, 30, 32, 52
|
||||
:linenos:
|
||||
|
||||
.. _example-chill-main-extension:
|
||||
|
||||
You should also adapt the :class:`DependencyInjection\*Extension` class to add ContainerBuilder and WidgetFactories :
|
||||
|
||||
.. literalinclude:: ./widgets/ChillMainExtension.php
|
||||
:language: php
|
||||
:emphasize-lines: 25-39, 48-49, 56
|
||||
:linenos:
|
||||
|
||||
- line 25-39: we implements the method required by :class:`Chill\MainBundle\DependencyInjection\Widget\HasWidgetExtensionInterface` ;
|
||||
- line 48-49: we record the configuration of widget into container's parameter ;
|
||||
- line 56 : we create an instance of :class:`Configuration` (declared above)
|
||||
|
||||
Compile the possible widget using Compiler pass
|
||||
-----------------------------------------------
|
||||
|
||||
For your convenience, simply extends :class:`Chill\MainBundle\DependencyInjection\Widget\AbstractWidgetsCompilerPass`. This class provides a `doProcess(ContainerBuildere $container, $extension, $parameterName)` method which will do the job for you:
|
||||
|
||||
- :code:`$container` is the container builder
|
||||
- :code:`$extension` is the extension name
|
||||
- :code:`$parameterName` is the name of the parameter which contains the configuration for widgets (see :ref:`the example with ChillMain above <example-chill-main-extension>`.
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection\CompilerPass;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Chill\MainBundle\DependencyInjection\Widget\AbstractWidgetsCompilerPass;
|
||||
|
||||
/**
|
||||
* Compile the service definition to register widgets.
|
||||
*
|
||||
*/
|
||||
class WidgetsCompilerPass extends AbstractWidgetsCompilerPass {
|
||||
|
||||
public function process(ContainerBuilder $container)
|
||||
{
|
||||
$this->doProcess($container, 'chill_main', 'chill_main.widgets');
|
||||
}
|
||||
}
|
||||
|
||||
As explained `in the symfony docs <http://symfony.com/doc/current/service_container/compiler_passes.html>`_, you should register your Compiler Pass into your bundle :
|
||||
|
||||
.. code-block:: php
|
||||
|
||||
namespace Chill\MainBundle;
|
||||
|
||||
use Symfony\Component\HttpKernel\Bundle\Bundle;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Chill\MainBundle\DependencyInjection\CompilerPass\WidgetsCompilerPass;
|
||||
|
||||
|
||||
class ChillMainBundle extends Bundle
|
||||
{
|
||||
public function build(ContainerBuilder $container)
|
||||
{
|
||||
parent::build($container);
|
||||
$container->addCompilerPass(new WidgetsCompilerPass());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,64 @@
|
||||
<?php
|
||||
# Chill\MainBundle\DependencyInjection\Configuration.php
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\Config\Definition\Builder\TreeBuilder;
|
||||
use Symfony\Component\Config\Definition\ConfigurationInterface;
|
||||
use Chill\MainBundle\DependencyInjection\Widget\AddWidgetConfigurationTrait;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
|
||||
/**
|
||||
* Configure the main bundle
|
||||
*/
|
||||
class Configuration implements ConfigurationInterface
|
||||
{
|
||||
|
||||
use AddWidgetConfigurationTrait;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var ContainerBuilder
|
||||
*/
|
||||
private $containerBuilder;
|
||||
|
||||
|
||||
public function __construct(array $widgetFactories = array(),
|
||||
ContainerBuilder $containerBuilder)
|
||||
{
|
||||
// we register here widget factories (see below)
|
||||
$this->setWidgetFactories($widgetFactories);
|
||||
// we will need the container builder later...
|
||||
$this->containerBuilder = $containerBuilder;
|
||||
}
|
||||
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function getConfigTreeBuilder()
|
||||
{
|
||||
$treeBuilder = new TreeBuilder();
|
||||
$rootNode = $treeBuilder->root('chill_main');
|
||||
|
||||
$rootNode
|
||||
->children()
|
||||
|
||||
// ...
|
||||
|
||||
->arrayNode('widgets')
|
||||
->canBeDisabled()
|
||||
->children()
|
||||
// we declare here all configuration for homepage place
|
||||
->append($this->addWidgetsConfiguration('homepage', $this->containerBuilder))
|
||||
->end() // end of widgets/children
|
||||
->end() // end of widgets
|
||||
->end() // end of root/children
|
||||
->end() // end of root
|
||||
;
|
||||
|
||||
|
||||
return $treeBuilder;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,59 @@
|
||||
<?php
|
||||
|
||||
#Chill\MainBundle\DependencyInjection\ChillMainExtension.php
|
||||
|
||||
namespace Chill\MainBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\WidgetFactoryInterface;
|
||||
use Chill\MainBundle\DependencyInjection\Configuration;
|
||||
|
||||
/**
|
||||
* This class load config for chillMainExtension.
|
||||
*/
|
||||
class ChillMainExtension extends Extension implements Widget\HasWidgetFactoriesExtensionInterface
|
||||
{
|
||||
/**
|
||||
* widget factory
|
||||
*
|
||||
* @var WidgetFactoryInterface[]
|
||||
*/
|
||||
protected $widgetFactories = array();
|
||||
|
||||
public function addWidgetFactory(WidgetFactoryInterface $factory)
|
||||
{
|
||||
$this->widgetFactories[] = $factory;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return WidgetFactoryInterface[]
|
||||
*/
|
||||
public function getWidgetFactories()
|
||||
{
|
||||
return $this->widgetFactories;
|
||||
}
|
||||
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
// configuration for main bundle
|
||||
$configuration = $this->getConfiguration($configs, $container);
|
||||
$config = $this->processConfiguration($configuration, $configs);
|
||||
|
||||
// add the key 'widget' without the key 'enable'
|
||||
$container->setParameter('chill_main.widgets',
|
||||
array('homepage' => $config['widgets']['homepage']));
|
||||
|
||||
// ...
|
||||
}
|
||||
|
||||
public function getConfiguration(array $config, ContainerBuilder $container)
|
||||
{
|
||||
return new Configuration($this->widgetFactories, $container);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,69 @@
|
||||
<?php
|
||||
|
||||
# Chill/PersonBundle/Widget/PersonListWidgetFactory
|
||||
|
||||
namespace Chill\PersonBundle\Widget;
|
||||
|
||||
use Chill\MainBundle\DependencyInjection\Widget\Factory\AbstractWidgetFactory;
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\Definition\Builder\NodeBuilder;
|
||||
|
||||
/**
|
||||
* add configuration for the person_list widget.
|
||||
*/
|
||||
class PersonListWidgetFactory extends AbstractWidgetFactory
|
||||
{
|
||||
/*
|
||||
* append the option to the configuration
|
||||
* see http://symfony.com/doc/current/components/config/definition.html
|
||||
*
|
||||
*/
|
||||
public function configureOptions($place, NodeBuilder $node)
|
||||
{
|
||||
$node->booleanNode('only_active')
|
||||
->defaultTrue()
|
||||
->end();
|
||||
$node->integerNode('number_of_items')
|
||||
->defaultValue(50)
|
||||
->end();
|
||||
$node->scalarNode('filtering_class')
|
||||
->defaultNull()
|
||||
->end();
|
||||
|
||||
}
|
||||
|
||||
/*
|
||||
* return an array with the allowed places where the widget can be rendered
|
||||
*
|
||||
* @return string[]
|
||||
*/
|
||||
public function getAllowedPlaces()
|
||||
{
|
||||
return array('homepage');
|
||||
}
|
||||
|
||||
/*
|
||||
* return the widget alias
|
||||
*
|
||||
* @return string
|
||||
*/
|
||||
public function getWidgetAlias()
|
||||
{
|
||||
return 'person_list';
|
||||
}
|
||||
|
||||
/*
|
||||
* return the service id for the service which will render the widget.
|
||||
*
|
||||
* this service must implements `Chill\MainBundle\Templating\Widget\WidgetInterface`
|
||||
*
|
||||
* the service must exists in the container, and it is not required that the service
|
||||
* has the `chill_main` tag.
|
||||
*/
|
||||
public function getServiceId(ContainerBuilder $containerBuilder, $place, $order, array $config)
|
||||
{
|
||||
return 'chill_person.widget.person_list';
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,129 @@
|
||||
<?php
|
||||
# Chill/PersonBundle/Widget/PersonListWidget.php
|
||||
|
||||
namespace Chill\PersonBundle\Widget;
|
||||
|
||||
use Chill\MainBundle\Templating\Widget\WidgetInterface;
|
||||
use Doctrine\ORM\EntityRepository;
|
||||
use Doctrine\ORM\Query\Expr;
|
||||
use Doctrine\DBAL\Types\Type;
|
||||
use Chill\MainBundle\Security\Authorization\AuthorizationHelper;
|
||||
use Symfony\Component\Security\Core\User\UserInterface;
|
||||
use Symfony\Component\Security\Core\Authentication\Token\Storage\TokenStorage;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
use Symfony\Component\Security\Core\Role\Role;
|
||||
use Doctrine\ORM\EntityManager;
|
||||
|
||||
/**
|
||||
* add a widget with person list.
|
||||
*
|
||||
* The configuration is defined by `PersonListWidgetFactory`
|
||||
*/
|
||||
class PersonListWidget implements WidgetInterface
|
||||
{
|
||||
|
||||
/**
|
||||
* Repository for persons
|
||||
*
|
||||
* @var EntityRepository
|
||||
*/
|
||||
protected $personRepository;
|
||||
|
||||
/**
|
||||
* The entity manager
|
||||
*
|
||||
* @var EntityManager
|
||||
*/
|
||||
protected $entityManager;
|
||||
|
||||
/**
|
||||
* the authorization helper
|
||||
*
|
||||
* @var AuthorizationHelper;
|
||||
*/
|
||||
protected $authorizationHelper;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var TokenStorage
|
||||
*/
|
||||
protected $tokenStorage;
|
||||
|
||||
/**
|
||||
*
|
||||
* @var UserInterface
|
||||
*/
|
||||
protected $user;
|
||||
|
||||
public function __construct(
|
||||
EntityRepository $personRepostory,
|
||||
EntityManager $em,
|
||||
AuthorizationHelper $authorizationHelper,
|
||||
TokenStorage $tokenStorage
|
||||
) {
|
||||
$this->personRepository = $personRepostory;
|
||||
$this->authorizationHelper = $authorizationHelper;
|
||||
$this->tokenStorage = $tokenStorage;
|
||||
$this->entityManager = $em;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param type $place
|
||||
* @param array $context
|
||||
* @param array $config
|
||||
* @return string
|
||||
*/
|
||||
public function render(\Twig_Environment $env, $place, array $context, array $config)
|
||||
{
|
||||
$qb = $this->personRepository
|
||||
->createQueryBuilder('person');
|
||||
|
||||
// show only the person from the authorized centers
|
||||
$and = $qb->expr()->andX();
|
||||
$centers = $this->authorizationHelper
|
||||
->getReachableCenters($this->getUser(), new Role(PersonVoter::SEE));
|
||||
$and->add($qb->expr()->in('person.center', ':centers'));
|
||||
$qb->setParameter('centers', $centers);
|
||||
|
||||
|
||||
// add the "only active" where clause
|
||||
if ($config['only_active'] === true) {
|
||||
$qb->join('person.accompanyingPeriods', 'ap');
|
||||
$or = new Expr\Orx();
|
||||
// add the case where closingDate IS NULL
|
||||
$andWhenClosingDateIsNull = new Expr\Andx();
|
||||
$andWhenClosingDateIsNull->add((new Expr())->isNull('ap.closingDate'));
|
||||
$andWhenClosingDateIsNull->add((new Expr())->gte(':now', 'ap.openingDate'));
|
||||
$or->add($andWhenClosingDateIsNull);
|
||||
// add the case when now is between opening date and closing date
|
||||
$or->add(
|
||||
(new Expr())->between(':now', 'ap.openingDate', 'ap.closingDate')
|
||||
);
|
||||
$and->add($or);
|
||||
$qb->setParameter('now', new \DateTime(), Type::DATE);
|
||||
}
|
||||
|
||||
// adding the where clause to the query
|
||||
$qb->where($and);
|
||||
|
||||
$qb->setFirstResult(0)->setMaxResults($config['number_of_items']);
|
||||
|
||||
$persons = $qb->getQuery()->getResult();
|
||||
|
||||
return $env->render(
|
||||
'ChillPersonBundle:Widget:homepage_person_list.html.twig',
|
||||
array('persons' => $persons)
|
||||
);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return UserInterface
|
||||
*/
|
||||
private function getUser()
|
||||
{
|
||||
// return a user
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,51 @@
|
||||
<?php
|
||||
|
||||
# Chill/PersonBundle/DependencyInjection/ChillPersonExtension.php
|
||||
|
||||
namespace Chill\PersonBundle\DependencyInjection;
|
||||
|
||||
use Symfony\Component\DependencyInjection\ContainerBuilder;
|
||||
use Symfony\Component\Config\FileLocator;
|
||||
use Symfony\Component\HttpKernel\DependencyInjection\Extension;
|
||||
use Symfony\Component\DependencyInjection\Loader;
|
||||
use Symfony\Component\DependencyInjection\Extension\PrependExtensionInterface;
|
||||
use Chill\MainBundle\DependencyInjection\MissingBundleException;
|
||||
use Chill\PersonBundle\Security\Authorization\PersonVoter;
|
||||
|
||||
/**
|
||||
* This is the class that loads and manages your bundle configuration
|
||||
*
|
||||
* To learn more see {@link http://symfony.com/doc/current/cookbook/bundles/extension.html}
|
||||
*/
|
||||
class ChillPersonExtension extends Extension implements PrependExtensionInterface
|
||||
{
|
||||
/**
|
||||
* {@inheritDoc}
|
||||
*/
|
||||
public function load(array $configs, ContainerBuilder $container)
|
||||
{
|
||||
// ...
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* Add a widget "add a person" on the homepage, automatically
|
||||
*
|
||||
* @param \Chill\PersonBundle\DependencyInjection\containerBuilder $container
|
||||
*/
|
||||
public function prepend(ContainerBuilder $container)
|
||||
{
|
||||
$container->prependExtensionConfig('chill_main', array(
|
||||
'widgets' => array(
|
||||
'homepage' => array(
|
||||
array(
|
||||
'widget_alias' => 'add_person',
|
||||
'order' => 2
|
||||
)
|
||||
)
|
||||
)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
93
docs/source/index.rst
Normal file
@ -0,0 +1,93 @@
|
||||
.. chill-doc documentation master file, created by
|
||||
sphinx-quickstart on Sun Sep 28 22:04:08 2014.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
.. Copyright (C) 2014 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Welcome to Chill documentation!
|
||||
=====================================
|
||||
|
||||
Chill is a free software for social workers.
|
||||
|
||||
Chill rely on the php framework `Symfony <http://symfony.com>`_.
|
||||
|
||||
Contents of this documentation:
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 2
|
||||
|
||||
installation/index.rst
|
||||
development/index.rst
|
||||
Bundles <bundles/index.rst>
|
||||
|
||||
Let's talk together !
|
||||
======================
|
||||
|
||||
Subscribe to the dev mailing-list to discuss your project and extend Chill with the feature you need!
|
||||
|
||||
- `The dev mailing-list <https://lists.chill.social/listinfo/dev>`_
|
||||
- `Read the archives of the mailing-list <https://lists.chill.social/pipermail/dev/>`_
|
||||
|
||||
|
||||
|
||||
Contribute
|
||||
==========
|
||||
|
||||
|
||||
* `Issue tracker <https://git.framasoft.org/groups/Chill-project/issues>`_ You may want to dispatch the issue in the multiple projects. If you do not know in which project is located your bug / feature request, use the project Chill-Main.
|
||||
* `The dev mailing-list <https://lists.chill.social/listinfo/dev>`_
|
||||
|
||||
Source code is dispatched in multiple bundle, to improve re-usability. Each bundle has dependencies with other chill bundle, but the developer take care that bundles may not be installed if the user do not need it.
|
||||
|
||||
User manual
|
||||
===========
|
||||
|
||||
An user manual exists in French and currently focuses on describing the main concept of the software.
|
||||
|
||||
`Read (and contribute) to the manual <https://fr.wikibooks.org/wiki/Chill>`_
|
||||
|
||||
Available bundles
|
||||
=================
|
||||
|
||||
* Chill-standard | https://git.framasoft.org/Chill-project/Chill-Standard This is the skeleton of the project. It does contains only few code, but information about configuration of your instance ;
|
||||
* Chill-Main : https://git.framasoft.org/Chill-project/Chill-Main : the main, required bundle for all the subsequent chill bundles. It contains the framework to add features (like searching, timeline, ...). It also provides the user managements (authentification and authorization) ;
|
||||
* Chill-Person : https://git.framasoft.org/Chill-project/Chill-Person This is the bundle which provides the possibility to create and add a person.
|
||||
* Chill-CustomFields : https://git.framasoft.org/Chill-project/Chill-CustomFields This bundle allows you to create custom fields on other bundles. It provides the framework for this features, and modify the schema according to this. It is required by Chill-Person and Chill-Report.
|
||||
* Chill-Report: https://git.framasoft.org/Chill-project/Chill-Report This bundle allow to add report about People recorded in your database ;
|
||||
* Chill-Activity : https://git.framasoft.org/Chill-project/Chill-Activity This bundle allow to add activities about People recorded in your database ;
|
||||
* Chill-ICPC2 : https://git.framasoft.org/Chill-project/Chill-ICPC2 This bundle provides a custom fields for `ICPC code <https://en.wikipedia.org/wiki/International_Classification_of_Primary_Care>`_ (international classification for primary care)
|
||||
* Chill-Group: https://git.framasoft.org/Chill-project/Chill-Group This bundle provides a way to create link between accompanyed people
|
||||
* Chill-Event: https://git.framasoft.org/Chill-project/Chill-Event This bundle provides a way to create event and associate people to event through a "participation"
|
||||
* Chill-Ldap: https://git.framasoft.org/Chill-project/Chill-Ldap Allow to synchronize the database with a ldap directory.
|
||||
* Chill-ONEStat : https://framagit.org/Chill-project/Chill-ONEStat Provide statistics for the Belgian one "Centre de vacances" and "Ecoles de devoir".
|
||||
|
||||
You will also found the following projects :
|
||||
|
||||
* The present documentation : https://git.framasoft.org/Chill-project/chill-documentation
|
||||
* The website https://chill.social : https://git.framasoft.org/Chill-project/chill.social
|
||||
|
||||
And various project to build docker containers with Chill.
|
||||
|
||||
TODO in documentation
|
||||
=====================
|
||||
|
||||
.. todolist::
|
||||
|
||||
Licence
|
||||
========
|
||||
|
||||
The project is available under the `GNU AFFERO GENERAL PUBLIC LICENSE v3`_.
|
||||
|
||||
This documentation is published under the `GNU Free Documentation License (FDL) v1.3`_
|
||||
|
||||
|
||||
.. _GNU AFFERO GENERAL PUBLIC LICENSE v3: http://www.gnu.org/licenses/agpl-3.0.html
|
||||
.. _GNU Free Documentation License (FDL) v1.3: http://www.gnu.org/licenses/fdl-1.3.html
|
||||
|
259
docs/source/installation/index.rst
Normal file
@ -0,0 +1,259 @@
|
||||
.. chill-doc documentation master file, created by
|
||||
sphinx-quickstart on Sun Sep 28 22:04:08 2014.
|
||||
You can adapt this file completely to your liking, but it should at least
|
||||
contain the root `toctree` directive.
|
||||
|
||||
.. Copyright (C) 2014-2019 Champs Libres Cooperative SCRLFS
|
||||
Permission is granted to copy, distribute and/or modify this document
|
||||
under the terms of the GNU Free Documentation License, Version 1.3
|
||||
or any later version published by the Free Software Foundation;
|
||||
with no Invariant Sections, no Front-Cover Texts, and no Back-Cover Texts.
|
||||
A copy of the license is included in the section entitled "GNU
|
||||
Free Documentation License".
|
||||
|
||||
Installation & Usage
|
||||
####################
|
||||
|
||||
|
||||
Requirements
|
||||
************
|
||||
|
||||
- This project use `docker <https://docker.com>`_ to be run. As a developer, use `docker-compose <https://docs.docker.com/compose/overview/>`_ to bootstrap a dev environment in a glance. You do not need any other dependencies ;
|
||||
- Make is used to automate scripts.
|
||||
|
||||
Installation in development mode
|
||||
********************************
|
||||
|
||||
1. Get the code
|
||||
===============
|
||||
|
||||
Clone or download the chill-standard project and `cd` into the main directory.
|
||||
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
git clone https://framagit.org/Chill-project/Chill-Standard.git
|
||||
cd Chill-Standard
|
||||
|
||||
|
||||
As a developer, the code will stay on your computer and will be executed in docker container. To avoid permission problem, the code should be run with the same uid/gid from your current user. This is why we get your current user id with the command ``id -u`` in each following scripts.
|
||||
|
||||
2. Prepare your variables
|
||||
=========================
|
||||
|
||||
Have a look at the variable in ``.env.dist`` and in ``app/config/parameters.yml.dist`` and check if you need to adapt them. If they do not adapt with your need, or if some are missing:
|
||||
|
||||
1. copy the file as ``.env``: ``cp .env.dist .env``
|
||||
2. you may replace some variables inside ``.env``
|
||||
|
||||
**Note**: If you intend to use the bundle ``Chill-Doc-Store``, you will need to configure and install an openstack object storage container with temporary url middleware. You will have to configure `secret keys <https://docs.openstack.org/swift/latest/api/temporary_url_middleware.html#secret-keys>`_.
|
||||
|
||||
3. Run the bootstrap script
|
||||
===========================
|
||||
|
||||
This script can be run using `make`
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make init
|
||||
|
||||
This script will :
|
||||
|
||||
1. force docker-compose to, eventually, pull the base images and build the image used by this project ;
|
||||
2. run an install script to download `composer <https://getcomposer.org>`_ ;
|
||||
3. install the php dependencies
|
||||
4. build assets
|
||||
|
||||
|
||||
4. Start the project
|
||||
====================
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose up
|
||||
|
||||
**On the first run** (and after each upgrade), you must execute *post update commands* and run database migrations. With a container up and running, execute the following commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make migrate
|
||||
|
||||
Chill will be available at ``http://localhost:8001.`` Currently, there isn't any user or data. To add fixtures, run
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
docker-compose exec --user $(id -u) php bin/console doctrine:fixtures:load
|
||||
|
||||
There are several users available:
|
||||
|
||||
- ``center a_social``
|
||||
- ``center b_social``
|
||||
|
||||
The password is always ``password``.
|
||||
|
||||
Now, read `Operations` below.
|
||||
|
||||
Operations
|
||||
**********
|
||||
|
||||
Build assets
|
||||
============
|
||||
|
||||
run those commands:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
make build-assets
|
||||
|
||||
How to execute the console ?
|
||||
============================
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# if a container is running
|
||||
docker-compose exec --user $(id -u) php bin/console
|
||||
# if not
|
||||
docker-compose run --user $(id -u) php bin/console
|
||||
|
||||
How to create the database schema (= run migrations) ?
|
||||
======================================================
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# if a container is running
|
||||
docker-compose exec --user $(id -u) php bin/console doctrine:migrations:migrate
|
||||
# if not
|
||||
docker-compose run --user $(id -u) php bin/console doctrine:migrations:migrate
|
||||
|
||||
|
||||
How to read the email sent by the program ?
|
||||
===========================================
|
||||
|
||||
Go at ``http://localhost:8005`` and you should have access to mailcatcher.
|
||||
|
||||
In case of you should click on a link in the email, be aware that you should remove the "s" from https.
|
||||
|
||||
How to load fixtures ? (development mode only)
|
||||
==============================================
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# if a container is running
|
||||
docker-compose exec --user $(id -u) php bin/console doctrine:fixtures:load
|
||||
# if not
|
||||
docker-compose run --user $(id -u) php bin/console doctrine:fixtures:load
|
||||
|
||||
How to open a terminal in the project
|
||||
=====================================
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# if a container is running
|
||||
docker-compose exec --user $(id -u) php /bin/bash
|
||||
# if not
|
||||
docker-compose run --user $(id -u) php /bin/bash
|
||||
|
||||
How to run composer ?
|
||||
=====================
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# if a container is running
|
||||
docker-compose exec --user $(id -u) php ./composer.phar
|
||||
# if not
|
||||
docker-compose run --user $(id -u) php ./composer.phar
|
||||
|
||||
How to access to PGADMIN ?
|
||||
==========================
|
||||
|
||||
Pgadmin is installed with docker-compose.
|
||||
|
||||
You can access it at ``http://localhost:8002``.
|
||||
|
||||
Credentials:
|
||||
|
||||
- login: admin@chill.social
|
||||
- password: password
|
||||
|
||||
How to run tests ?
|
||||
==================
|
||||
|
||||
Tests reside inside the installed bundles. You must `cd` into that directory, download the required packages, and execute them from this place.
|
||||
|
||||
**Note**: some bundle require the fixture to be executed. See the dedicated _how-tos_.
|
||||
|
||||
Exemple, for running test inside `main` bundle:
|
||||
|
||||
.. code-block:: bash
|
||||
|
||||
# mount into the php image
|
||||
docker-compose run --user $(id -u) php /bin/bash
|
||||
# cd into main directory
|
||||
cd vendor/chill-project/main
|
||||
# download deps
|
||||
php ../../../composer.phar install
|
||||
# run tests
|
||||
/vendor/bin/phpunit
|
||||
|
||||
How to run webpack interactively
|
||||
================================
|
||||
|
||||
Executing :code:`bash docker-node.sh` will open a terminal in a node container, with volumes mounted.
|
||||
|
||||
Build the documentation API
|
||||
===========================
|
||||
|
||||
A basic configuration of `sami <https://github.com/FriendsOfPhp/Sami>`_ is embedded within the project.
|
||||
|
||||
A configuration file for `phpDocumentor <https://www.phpdoc.org>`_ is present.
|
||||
|
||||
Error `An exception has been thrown during the rendering of a template ("Asset manifest file "/var/www/app/web/build/manifest.json" does not exist.").` on first run
|
||||
====================================================================================================================================================================
|
||||
|
||||
Run :code:`make build-assets`
|
||||
|
||||
Running in production
|
||||
*********************
|
||||
|
||||
Currently, to run this software in production, the *state of the art* is the following :
|
||||
|
||||
1. Run the software locally and tweak the configuration to your needs ;
|
||||
2. Build the image and store them into a private container registry. This can be done using :code:`make build-and-push-image`.
|
||||
|
||||
To be sure to target the correct container registry, you have to adapt the values ``IMAGE_NGINX`` and ``IMAGE_PHP`` date in the ``.env`` file.
|
||||
3. Run the image on your production server, using docker-compose or eventually docker stack. You have to customize the variable set in docker-compose.
|
||||
|
||||
See also the :ref:`running-production-tips-and-tricks` below.
|
||||
|
||||
.. warning::
|
||||
|
||||
In production, you **must** set those variables:
|
||||
|
||||
* ``APP_ENV`` to ``prod``
|
||||
* ``APP_DEBUG`` to ``false``
|
||||
|
||||
There are security issues if you keep the same variable than for production.
|
||||
|
||||
|
||||
.. _running-production-tips-and-tricks:
|
||||
|
||||
Tips and tricks
|
||||
===============
|
||||
|
||||
Operation on database (backups, running custom sql, replication) are easier to set when run outside of a container. If you run into a container, take care of the volume where data are stored.
|
||||
|
||||
The PHP sessions are stored inside redis. This is useful if you distribute the traffic amongst different php server: they will share same sessions if a request goes into a different instance of the container.
|
||||
|
||||
When the PHP servers are shared across multiple instances, take care that some data is stored into redis: the same redis server should be reachable by all instances.
|
||||
|
||||
It is worth having an eye on the configuration of logstash container.
|
||||
|
||||
|
||||
Design principles
|
||||
*****************
|
||||
|
||||
Why the DB URL is set in environment, and not in parameters.yml ?
|
||||
=================================================================
|
||||
|
||||
Because, at startup, a script does check the db is up and, if not, wait for a couple of seconds before running ``entrypoint.sh``. For avoiding double configuration, the configuration of the PHP app takes his configuration from environment also (and it will be standard in future releases, with symfony 4.0).
|
||||
|